Call Main Function Explicitly

Can we call the main function explicitly? If Yes, How?

Questions by sahil5

Showing Answers 1 - 3 of 3 Answers

Raghunadh Parlapalli

  • Feb 13th, 2013
 

Thats an excellent question.
Try this, It works. Because main() is a static method. So, We can call static methods from another class static method.

ClassB {
public static void main(String[] args) {
System.out.println("ClassB main() Called");
}
}

ClassA {
public static void main(String[] args) {
System.out.println("ClassA main() Called");
ClassB.main(args);
}
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions