aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Another version of main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Another version of main method" Watch "Another version of main method" New topic
Author

Another version of main method

nish vatsa
Greenhorn

Joined: Oct 20, 2005
Posts: 6
Just try dis:

public static void main(String... args) {
System.out.println("nis");
}


It will compile fine and morever it run correctly and output is nish
Amit Sharma
Ranch Hand

Joined: Nov 22, 2005
Posts: 87
check it again its not working


Amit Sharma SCJP 1.4, SCWCD 5, OCUP-100(UML)
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

no its not working. which version of java are you using?. i am using 1.4.2_05.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
nish vatsa
Greenhorn

Joined: Oct 20, 2005
Posts: 6
its working fine

public class Test {
public static void main(String... args) {
System.out.println("nis");
}


}

u r missing somewhere...
nish vatsa
Greenhorn

Joined: Oct 20, 2005
Posts: 6
just check the JLS specification at

http://java.sun.com/docs/books/jls/third_edition/html/execution.html

it mentioned as .........

The method main must be declared public, static, and void. It must accept a single argument that is an array of strings. This method can be declared as either


public static void main(String[] args)

or

public static void main(String... args)

i ran it using jdk1.5
Enge Chall
Ranch Hand

Joined: Nov 22, 2005
Posts: 30
That varargs is jdk 1.5 upward compartible. enjoy !!


Not everything that counts can be counted, and not everything that can be counted counts.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Another version of main method