This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 19656
    
  18

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: 38107
    
  22
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.
 
Consider Paul's rocket mass heater.
 
subject: Cant compile code with var-args
 
Similar Threads
overriding meth(String... i) wih meth(String[] i)......
Can anyone explain executing at runtime vs compile?
Ver args Vs Array..!!
validate() method & validation.xml
Final variables