Concepts In Java

  • public static void main(String args[])?
  • Note: First of all, Java is a case-sensitive language so there is a difference between main and Main.
  1. public is the access specifier. It is used because it can be accessed outside the class also as the main method is called by JVM(Java Virtual Machine) outside the class. So we have to use the keyword public.
  2. If the method is static then we don’t have to make the object of the class. As the main method doesn’t belong to a particular object.
  3. void means no return value. This means the main method will not return any value.
  4. The ‘String’ is a predefined class. args is an array and you can change the name because it is a variable.
  • Ways to write the main method in Java:
  1. public static void main(String args[])
  2. public static void main(String tanmay[])
  3. public static void main(String []args)
  4. public static void main(String …args)
  • System.out.println();
  1. This syntax is used to print the statement, value etc.
  2. Here System is the predefined class and it is defined is the java.lang package.
  3.  out is an object and static field of the class and it is used with three keywords public static final.
  4. System.out.print will print the text but the cursor will be on the same line so we use println because after printing the text the cursor should be on the next line. 
  5. println is the method of PrintStream.

Leave a Reply