In this tutorial, we will learn how to write a Hello World program in Java language. We will go through each statement of the program.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Hello, World!
public class HelloWorld
HelloWorld
. In Java, every application must have at least one class definition that contains the main method.public static void main(String[] args)
public
keyword means the method is accessible from anywhere, static
means it belongs to the class rather than instances of the class, void
means it does not return any value, and main
is the name of the method. String[] args
is the parameter to the main method, which is an array of strings.{
System.out.println("Hello, World!");
System.out
is a standard output stream, and println
is a method that prints a line of text followed by a newline.}
}
HelloWorld
class definition.