Can we overload main() method?

class MainMethod3
{
public static void main(String[] args)
{
System.out.println("String[] args");
}
public static void main(int[] args)
{
System.out.println("int[] args");
}
}
/*
Output:-
Explanation:- Yes we can overload main() method but JVM will always call "String[]" argument
main() method only. The other overloaded method we have to call explicitly then
it will be excuted just like a normal method call.
*/

0 comments: