Interviews1 answer
How to call main() from a class (not containing the main function) in a java program?
1 Answer
Just like any other method (static) call you can call main method...
I am sending a small code example which may be helpful
PS : NOT COMPILED AND NOT TESTED...
for example...
class ClassContainingMainMethod
{
public static void main(String ax[])
{
// your code ...
}
}
class YourClass
{
public void yourMethod()
{
// your code ...
String[] ax = new String[1];
ClassContainingMainMethod.main(ax);
}
}
joy fortunePosted Sep 29, 2007, 4:14 PM EDT