Subscribe Us

header ads

First Program in Java

To Print "Hello Java Programming Language"

class demo
{
    public static void main(String 
args[])
    {
        System.out.println("Hello 
Java Programming Language");
    }
}


To compile : javac demo.java
To run : java demo
Output : Hello Java Programming Language



Understanding First Java Program :-
  • class keyword is used to declare a class in java.
  • public is an access modifier, it is visible to all.
  • static is a keyword. If we declare any method as static, it is known as the static method. The core advantage of the static method is that there is no need to create an object to invoke the static method. The main method is execute by the JVM, so it doesn't required to create an object to invoke the main method. So it saves memory.
  • void is the return type of the method, it means it doesn't return any value.
  • main represents the startup of the program.
  • String args[] is used for command line argument.
  • System.out.println() is used to print statement. Here System is a class and out is the object of Printstream class, println is the method of Printstream class.

Post a Comment

0 Comments