← Chapter 2 — Core Syntax & Data

4. Java Program Structure & Output

mixed

Description

A Java application usually starts in the main method. Statements inside its braces run from top to bottom unless control flow changes that order.

System.out.println displays a value followed by a new line. Use it often while learning to inspect what your program is doing.

Subtopics

Class and main method

Description

A class groups Java code.

Explanation

main is the entry point for a simple command-line program.

Example

public static void main(String[] args) { }

Printing text

Description

Output helps communicate results.

Explanation

println adds a line break; print does not.

Example

System.out.println("Score: 92");

Explanation

Java is case-sensitive: System and system are different names. A semicolon ends most statements, while braces define a block of related statements.

Example

public class OutputDemo {
    public static void main(String[] args) {
        System.out.println("Aditi's score: 92");
        System.out.print("Keep learning ");
        System.out.println("Java!");
    }
}

Key points

  • main is an application entry point.
  • println adds a new line.
  • Java is case-sensitive.

Open reference