This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Meaning of  Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Meaning of  "int... j"" Watch "Meaning of  "int... j"" New topic
Author

Meaning of "int... j"

Suresh Rajadurai
Ranch Hand

Joined: Feb 22, 2007
Posts: 58
Hi,

I am preparing for Java certification, I came across a method declaration in a mock question.

public void methodX(int i, int... j)

Can anybody explain the meaning of "int... j"?

Thanks.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Take a look at this article.
http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

In short, it means "int[] i" with the difference that when calling this method, you don't need to explicitly create the array.

For example:

In the last four lines, the compiler creates an array for you. In the last case, this will be an empty array.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Meaning of "int... j"
 
Similar Threads
flow controls
How can I access a variable outside a loop when I set in it inside the loop?
Error in code when using assertion
forward reference doubt
concurrent bubble sort