Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integer array

 
Misbha Ali
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let me know how to form an Integer array.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Gary Mann
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer[] integerArray = new Integer[10]; // define
// populate
for (int i = 0; i < integerArray.length; ++i) {
integerArray[i] = new Integer(i * 10);
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic