Here are some basic Java syntax rules:
4. Java comments start with //
for single-line comments, or /
and end with /
for multi-line comments.
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:
int num = 10;
String message = "Hello, World!";
System.out.println("Hello, World!");
import java.util.Scanner;
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();