24 Dec 2017

Different way to handle with main method.

Today Here,we are going to see the all of various way we can declare the main method.in which some of them passes the compilation and some of them fail to compile and like this all the possiblity is given here. so lets have a look here to aware with main() method.

Sn Method  CE RE Error Message
    1 public static void main(String[]  args) no no no error
     2 public static void main(String  []args) no no no error
    3 public static void main(String args[]) no no no error
    4 public static void main([]String args) yes  illegal start of type
    5 public static void main(String  []abc) no no no error
     6 static public  void main(String[] args) no no no error
     7 public static void main(String... args) no no no error
     8 public static int main(String[]  args) yes missing return statement
    9 public static void mian(String[]  args) no yes main method not found in class 
    10 public static void main(String[5] args) yes size can not be given here
    11 public static void main(int[] args) no yes main method not found in class 
    12 public static void main(String  args) no yes main method not found in class 
   13 public static void main() no yes main method not found in class 
   14 static void main(String[] args) no yes main method not found in class 
   15 public  void main(String[] args) no yes main method is not static in class
   16 void main(String[] args) no yes main method not found in class 
  17 public static final synchronized void main(String[] args) no no no error
  18 protected static void main(String[] args) no yes main method not found in class 
  19 public static void main(String.* args) yes identifier expected
   20 public static final void main(String[] args) no no no error
   21 private static void main(String[] args) no yes main method not found in class 
   22 public static void main(String...[] args) yes identifier expected,illegal start of type
   23 public static void main(String[]... args) no yes main method not found in class