First program in Java
Open an editor like: Notepad, Sublime etc and write.
public static void main(String args)
Save this file as “HelloWorld.java” (save as Class name)
Go to command prompt: (javac for compile and java for run)
Details first java program
Let’s see what is the meaning of class, public, static, void, main, String, System.out.println().
- class( keyword) is used to declare a class in java.
- public keyword is an access modifier which is visible to all.
- static keyword no need to create an object to call the static method. The main method is executed by the JVM.
- void is the return type of the method which means return no value.
- main is method where all program start.
- String args is used for command line argument.
- System.out.println() method is used print the statement.