Skip to content

Java Hello World

Java Hello World Program

java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Java Hello World Program Explained

  • The public keyword is an access modifier that allows the HelloWorld class to be accessible to all other classes in the same package.
  • The class keyword is used to declare a class in Java.
  • The HelloWorld is the name of the class.
  • The main is the name of the method.
  • The String[] args is the parameter of the main method.
  • The System.out.println() is used to print the text to the console.
  • The Hello World! is the text that is printed to the console.

Java Hello World Program Output

shell
Hello World!
Hello World!