bscodinglab

Frist Program In Java

We will learn how to write the simple program of Java. Hare we can write a simple Java program to print “Hello World” .

Program :-

      public class demo
       {
         public static void main(String []args)
          {
             System.out.print("Hello World");
          }
       }

Output :- Hello World

What have we used in the first program and why
  1. class :- class keyword is used to declare a class in Java.
  2. public :- public keyword is an access modifier that represents visibility. Public is visible to all.
  3. static :- If we declare any method as static by static keyword, that is known as the static method. the static method is that there is no need to create an object to invoke the static method.
  4. void :- void is the return type of the method. it doesn’t return any value.
  5. main :- the starting point of the program. The main() method is executed by the JVM, so it doesn’t require creating an object to invoke the main() method.
  6. String[] args or String args[] :- It is used for command line argument(it pass as parameter in main method).
  7. System.out.println() :- is used to print statement.