In Java , why cant the main method be called inside the main method ? Like a recursive function.
See the following code It gives an error (Why?) : abstract class Parent { public static void main (String[] arg) { System.out.println("\n This is the Parent class"); Sub_class_1 obj1 = new Sub_class_1(); Sub_class_2 obj2 = new Sub_class_2(); obj1.message(); obj2.message(); for ( int i=1; i<=3; i++ ) { main(); /* Since main method is static , hence no object . Also , main method is in the class Parent , and we are calling main method inside the class , so only function is name is enough (no class required ). */ } } } class Sub_class_1 extends Parent { public void message() { System.out.println("\n This is first subclass"); } } class Sub_class_2 extends Parent { public void message() { System.out.println("\n This is second subclass"); } }