aspose file tools*
The moose likes Beginning Java and the fly likes Cant compile code with var-args Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cant compile code with var-args" Watch "Cant compile code with var-args" New topic
Author

Cant compile code with var-args

P Teng
Greenhorn

Joined: Nov 20, 2009
Posts: 16
I can't get a code with a method containing var-arg to compile.

System.getProperty("java.version") in the code returns 1.5.0_10

what could be wrong ?

Method signatute is as below

static void aMethod (String... y)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

What is the compiler output?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39869
    
  28
Welcome to JavaRanch

Have you got a space before the ... ? It might require a space.
Have you got a method whose signature only differs by having [] instead of ... ? If so, the compiler will interpret those two signatures as identical and fail to compile.
Execute this command javac -version at the command line to confirm which version of compiler you have in your PATH.
P Teng
Greenhorn

Joined: Nov 20, 2009
Posts: 16
Thanks guys, it must be one of the PATH settings or the version. The same code works at home. Thanks Ritchi ! Hope to hear/tell/learn lot more in the forum in the future.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cant compile code with var-args