Hello World Java Program

this is the first java program, which explains the anatomy of a java class

public class helloWorld {

	public static void main(String[] args) {
		System.out.println("Hello world");
	}
}

let’s start with class :-

public so that anyone can access it
class java keyword to declare a class
helloWorld name of the public class, the name of the public class should be same as program name, because there is only entry point, to enter a program.

now consider the main method :-

public so that anyone can call this method
static every class is accessed with objects, so need to create object in order to access this class. But in order to not access this class with object, we declare it static so that this function will be accessed without creating helloWorld class object.
void this function not returning any value to the calling block
main(String args[ ] ) : main( ) is the starting point of any java class, execution of instructions are starting from here onwards. String args[] are the command line arguments which are passed to java program while executing. example explained further.

In order to execute this program we have to perform 2 steps like this : –

Now, consider an example of Command line arguments


public class helloWorld {

	public static void main(String[] args) {
		System.out.println(args[0]);
		System.out.println(args[1]);
	}
}