class  Example {

//program begins here.

public static void main(String args[]){

System.out.println(“Hi, This is my first Java program.”);

}

}

This is a simple program to print a line “Hi, This is my first Java program.”

There are some key points that should be known to you:

  1. Here ‘class’ is a keyword that is used for creating new class and first letter of every class name should be capital. The whole class definition, including all of its members i.e. variables & methods will be defined in between of  curly braces ({ }).
  2. // is used for a single line comment. and for multi-line comment we use /**/.
  3. public static void main(String args[]),is a public method from where every program starts to run.
  4. Here public is a keyword that shows that method is public used from everywhere.
  5. static is also a keyword, that gives power to the method to be called by class name. There is no need to create a object call. Because of this feature, the main() is also called by the Java virtual machine before any object is instantiated.
  6. void is keyword, is shows that method is not going to return anything.
  7. main is the name of the method.
  8. String is class name. we are not going to discuss it here.
  9. args is the array of argument of String type.
  10. System.out.println(), is calling of method println().println() is used for printing a line that is passed as the argument to the method.
  11. Every line should ends with the semicolon (;). It shows that line terminates here.

Output-

Leave a Reply

Your email address will not be published. Required fields are marked *