Deepa:
A small correction...hope you don't mind..
"You cant have two mains ...same file."
This sentence should be
"You can't have two main in the same program /same file
with the same signature."
You could defenitely have two mains like this:
public static void main(String[] args){
// conventional main, method.
}
public static void main (Integer[] argv){
// overloaded main method, with different
// input argument type.
}
Check it out.
So, the answer to the original question:
1. Yes, we can have as many main methods in a class
as we want, but they should have different signatures.
2. In the original code above, the two main() methods
are in different classes. That is not same as the one
I said above. Hence the code compiles. Now, why you want
to do this is a different discussion altogether.
Hope this helps.
Regds.
- satya