Monday, April 13, 2020

About main() method in java

public static void main(String args[]){
}

Why 

  1. public  ----- so that jvm can get control of main method from anywhere
  2. static ---- so that main method could be accessed without any object reference
  3. void .... main method does not return value
  4. String args[]  ---- when you are executing jar file with java class with main method in it. we can pass String arguments to main method if needed.

No comments:

Post a Comment