[Back to Home](../README.md#java)
# The Overview of Java Basic Syntax
Here are some basic Java syntax rules:
# List Of Content
## 1. Java code is case-sensitive.
## 2. The code is written in classes.
## 3. Each statement must end with a semicolon `;`.
## 4. Java comments start with `//` for single-line comments, or `/`and end with `/` for multi-line comments.
## 5. Java uses the curly brace `{}` to define the scope of methods and classes.
## 6. The main method is the entry point of a Java program and is defined as follows:
```java
public static void main(String[] args) {
// code goes here
}
```
## 7. To declare a variable, use the data type followed by the variable name, and optionally an initial value:
```java
int num = 10;
String message = "Hello, World!";
```
## 8. To output a message to the console, use the `System.out.println()` method:
```java
System.out.println("Hello, World!");
```
## 9. To get input from the user, use the Scanner class:
```java
import java.util.Scanner;
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
```