| Is it is possible to overload java main() method?
Yes we can have any number of main() methods in java program. And to accomplish this we use method overloading. In below example we have JVM calls main() method which receives string array as arguments only.
class OverloadingTest
{
public static void main(String[] args1) {
System.out.println("main with String[] array");
}
public static void main(String args2){
System.out.println("main with String only");
}
public static void main()
{
System.out.println("main without args");
}
}
| | |