jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes main() method... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "main() method..." Watch "main() method..." New topic
Author

main() method...

Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
If a java programme has two main methods with same signature.... wat will happen..........


$Hi/\bEr
Ganesha Kumar
Ranch Hand

Joined: May 04, 2006
Posts: 56
You cannot have two methods with the same signature in a single Java file
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
then it will give compile time error.. is it?..... wat happens if i have String[] args as arg for one main() and String[] argv for another...
Chad Brown
Greenhorn

Joined: Jun 16, 2006
Posts: 1
The simple solution is to write a program with two main methods e.g.

public class TwoMains{

public static void main(String args[]){
}

public static void main(String[] args){
}

}

Compile it and you should get a compiler error stating that main has already been defined.
[ June 16, 2006: Message edited by: Chad Brown ]
Amod Mulay
Ranch Hand

Joined: Apr 06, 2006
Posts: 33
Originally posted by Shiaber:
then it will give compile time error.. is it?..... wat happens if i have String[] args as arg for one main() and String[] argv for another...


hey change the argument to string,string and see what happens..it will compile....but compiler will always look for the main(String[] df)
sugniture first as it passes some default string can be empty to the main methpd for execution
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: main() method...
 
Similar Threads
First GUI program
java.lang.NoSuchMethodError
run time error
packaging runme.jar
WA #1.....word association