sir, i want to know that can a main method of a class be invoked in another class,if yes how .explain me with an example.
Joined: Mar 11, 2002
You can do it. I don't know why you need someone to provide an example. Why can't you write 2 classes and try calling the main method of one class from the main method of another class?
Joined: Mar 22, 2004
The only thing special about main is that it's the one that gets run if you say 'java SomeClass' on the command line. Of course it only works if the signature is just perfect (static, with string array for parm, you know). I wouldn't call it, though. I'd do something like this if I had the need: