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 The Variable Arity parameter from the department of obfuscation 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 "The Variable Arity parameter from the department of obfuscation" Watch "The Variable Arity parameter from the department of obfuscation" New topic
Author

The Variable Arity parameter from the department of obfuscation

Shamsudeen Akanbi
Ranch Hand

Joined: Dec 24, 2010
Posts: 71
Hi there I dont know which arguments a var-arg lists accepts; i mean i need an illustration. Or is it possible for this code to work: void setValues(int... sizes) {
// my set values code goes here
}
what types of argument, how should it be formatted and
what's the maximum parameters that can go in there.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38100
    
  22
The type of each argument is given by the type you have given, there is no set number, and they are aggregated into an array. If you write... numbers has the type of int[] inside the foo method. Note that foo(int ... numbers) and foo(int[] values) are overload-equivalents to each other, and cannot be compiled together.

Try this Java™ Tutorials section.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: The Variable Arity parameter from the department of obfuscation
 
Similar Threads
for loop question
assignments and + operator
lockCookie
Access a variable
JSP called from filter not finding JavaScript file