Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Can we overload main() method?

Yes, by method overloading. You can have any number of main methods in a class by method
overloading. Let's see the simple example:
1.

class Overloading1{

2.

public static void main(int a){

3.

System.out.println(a);

4.

5.
6.

public static void main(String args[]){

7.

System.out.println("main() method invoked");

8.

main(10);

9.

10.

}
Test it Now

Output:main() method invoked


10

You might also like