aspose file tools*
The moose likes Java in General and the fly likes var arg in method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "var arg in method" Watch "var arg in method" New topic
Author

var arg in method

saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84


when i pass the primitive variables such as c or b with reference of int array
object(a) i am getting error ...why


"I Love Java Ranch"
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4366
    
    8

The var-arg method will take either an int array, or any number of int parameters. But you can't mix them.
saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84
why the java developers avoids this
is there any performance degradation..any other reason
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4366
    
    8

It's just how the language is designed. And there are pretty good reasons for the design - you'd run into problems with overloaded methods where it was ambiguous which version was called. But fundamentally, this is one of those questions where the answer is "because that's how it works".

saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84
thanks for sharing information ...

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: var arg in method