Thuta Learning
BasicProgrammingbeginner

Syntax & Hello World

Relax. We'll talk through this in plain words — no textbook voice.

Every Java program needs at least one class. Code is organized neatly inside blocks { }, and every statement must end with a semicolon ;. Java is case-sensitive, so Main and main are not the same. Java keeps very close track of capitalization—it's basically in exam-invigilator mode at all times.

java
public class Main {
  public static void main(String[] args) {
    // Program starts here
    System.out.println("Hello World");
  }
}

public class Main is a class declaration. public static void main(String[] args) is the main method of a Java program, and it's the method the JVM looks for and runs first. A comment line starting with // isn't code—it's just a note left by the developer.

You should see
Hello World

Real-world use

Once you're comfortable with the syntax, you'll pick up much faster on "which block handles which responsibility" when reading framework code later on.

Easy traps

  • Writing Public with a capital P, writing String as string, or forgetting to close a brace will all cause compile errors.
Syntax & Hello World | Thuta Learning