This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cant compile code with var-args" Watch "Cant compile code with var-args" New topic

Cant compile code with var-args

P Teng

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

Joined: Oct 27, 2005
Posts: 20078

What is the compiler output?

How To Ask Questions How To Answer Questions
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43935
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

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Cant compile code with var-args
It's not a secret anymore!