permaculture playing cards*
The moose likes Java in General and the fly likes Integer array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Integer array" Watch "Integer array" New topic
Author

Integer array

Misbha Ali
Greenhorn

Joined: Jul 22, 2003
Posts: 7
Please let me know how to form an Integer array.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,
"How to form an Integer array." Hmmm. Well, using "new", the way you create all other kinds of arrays, or using direct initialization. A few examples:

Now, given that you're asking this question, it's possible that you don't mean java.lang.Integer objects at all, but arrays of int primitives. So I'll show those too:

OK?


[Jess in Action][AskingGoodQuestions]
Gary Mann
Ranch Hand

Joined: Jun 05, 2003
Posts: 37
Integer[] integerArray = new Integer[10]; // define
// populate
for (int i = 0; i < integerArray.length; ++i) {
integerArray[i] = new Integer(i * 10);
}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Integer array
 
Similar Threads
int---->integer array
array
ArrayList and integers
Why this compiles
Question of Arrays.asList()