Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Java » Breakup of 'Hello World' Program in Java


Breakup of 'Hello World' Program in Java

This example explains each and every symbol & keyword used in 'Hello World' program in Java.

Breakup of 'Hello World' Program (very useful to know for Java beginners)

  • { }
  • ( )
  • public
  • class
  • public Class Main
  • public static void main()
  • String[] args
  • System.out.println()
  • " "
  • ;


Example:


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

  • { }
  • - these are called opening and closing braces. some of us also called it curely braces but ideally in programming context these are Braces only.

  • ( )
  • - these are called opening and closing parentheis. some of us also called it bracket but ideally in programming context these are Parenthesis only.

  • public
  • - public is basically keyword (predefined/reserved word by java) but known as access specifier. fresher should just remember that it is used classes, variables to make them accessible from outside world. You will get deeper knowledge on this in next lessons.

  • class
  • - class is also a keyword (predefined/reserved word by java). This keyword is used create our own data type which can have Data Member(variables) and Member Functions.

  • public class Main
  • - Here we are creating 'Main' class since it is preceded by 'class' keyword. Public means this class is accessbile by othe programs.

  • public static void main()
  • - Main() is predfined method which is must to define in the project. Every project has atleast one Main() method.
    - void means the Main() methods would not return any value (detail on this you will find in next chapters)
    - static is again a keyword. Main() method should preceds with static keword to run the code

  • String[] args
  • - args is array of string. this is known syntax which is called command line argument if used with Main(String[] args)

  • System.out.println()
  • - System is a class
    - out is PrintStream object
    - println() method to print text on screen

  • " "
  • - This is know as double quotes in java. Usually strings are put inside double quotes.

  • ;
  • - this is called semicolumn, it is also known as statement terminator in Java

Note: Java is case sensitive langauge. Class and class are two different word for Java