Yes, it is possible to have more than one main method but with different signature.
class a
{
public static void main(String[] args)
{
System.out.println("hello");
main(5);
a object1 = new a();
object1.main('a');
}
public static void main(int a)
{
System.out.println("call to static method from static method");
}
public void main(char c)
{
System.out.println("call to non-static method from static method can only be done through class reference");
}
}
OUTPUT:
hello
call to static method from static method
call to non-static method from static method can only be done through class reference
class a
{
public static void main(String[] args)
{
System.out.println("hello");
main(5);
a object1 = new a();
object1.main('a');
}
public static void main(int a)
{
System.out.println("call to static method from static method");
}
public void main(char c)
{
System.out.println("call to non-static method from static method can only be done through class reference");
}
}
OUTPUT:
hello
call to static method from static method
call to non-static method from static method can only be done through class reference