First Program
class Simple {
public static void main (string args []) {
System.out.println ("Hello Java");
}
}
save this file as Simple.java
To compile: javac Simple.java
To execute: java Simple
It will give output as Hello Java
Let's see what this is:
class keyword is used to declare a class in java.
Public keyword is an access modifier which represents visibility, it means it is visible to all.
static is a keyword, if we declare any method as static, it is known as static method. The main method is executed by the JVM, it does not require the object to invoke the main method. So it saves memory.
The void is the return type of method, it means it does not return any value.
main is a entry point of the program. Execution of programs starts from main. It is called by Runtime System
String [] args is used for command line argument. We will learn it later.
System.out.println () is used print statement.