| Author |
Can we add two main method in a single class have same signature.
|
gauraw gupta
Greenhorn
Joined: Apr 10, 2011
Posts: 5
|
|
Hi,
Can it possible to add two main method public static void main(String args[]) in a single class.
Also please provide me the some information that a Class and Object are a simple class or abstract class or interface.
Thanks
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
gauraw gupta wrote:Can it possible to add two main method public static void main(String args[]) in a single class.
Have you already tried? If yes, what were the results? And why would you get those results?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Madhan Sundararajan Devaki
Ranch Hand
Joined: Mar 18, 2011
Posts: 312
|
|
|
You cannot, as it will result in compilation error. The reason being JVM will not know which method to invoke.
|
S.D. MADHAN
Not many get the right opportunity !
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8433
|
|
Also please provide me the some information that a Class and Object are a simple class or abstract class or interface.
Recommended reading: http://www.coderanch.com/how-to/java/InterfaceVsAbstractClass
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9940
|
|
can you ever have two methods with the exact same signature, regardless of the name, in a single class? Why would 'main' be any different?
if you did have it in there twice, how would the JVM decide which one to use when it starts?
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
 |
|
|
subject: Can we add two main method in a single class have same signature.
|
|
|