+ 2
Which Main() will execute if there's two Main()'s in java program?
In other languages if there are 2 main()'s compiler will cause error but in java, compiler executes it successfully. Even calling Main() from Main() will cause infinite loop but in java I loved it ,it accepts two Main()'s. Can anyone tell me hows that happening and how's that possible?
1 Odpowiedź
+ 1
Main method cannot be overridden so it will throw an error. But it can be overloaded and in that case both the main methods will execute successfully.