Java program structure and the main method

This Java program declares a local variable and prints it from a main method.

A simple example

Follow one calculation

  1. Start with 2 and 3
  2. Do this Add, then print
  3. Result 5
The addition finishes before the program prints its result.
Main.java
class Main {
    public static void main(String[] args) throws Exception {
        System.out.println(2 + 3);
    }
}
Output
5