First Java Program

 First Java Program :- 




To compile:
javac Demo.java

To execute:
java Demo



public :- 
The access modifier of the main method needs to be public so that the JRE can access and execute this method. 

Static :-
When the Java program starts, there is no object of the class present. The main method has to be static so that the JVM can load the class into memory and call the main method without creating an instance of the class first.

void
Every Java method must provide the return type. The Java main method return type is void because it doesn’t return anything.

main
The Java main method is always named main. When a Java program starts, it always looks for the main method. 

String[] args
Java main method accepts a single argument of type String array. Each string in the array is a command line argument.


Post a Comment

0 Comments