Can We overload main method ??

Point here is that main() is no different from any other method.
You can overload it, you can have it or even not have it. It is all valid java. The only time it matters is when you want to START your program. The JVM looks for the main method with the signature of "public static void main(String [] args)"    'or'    "public static void main (String...arg)"
Note- but you can't have both String [] args  & String...args in same class because both take same types and same number of arguments so it will be a compile time error. 
So, the answer is Yes, we can overload main method.

No comments:

Post a Comment