Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

growable array of primitive type

 
Pin Ting
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all ranchers,
The Vector and ArrayList accept object only, and I found it not convenient to use. So I wonder is there any easy way to do this in Java:
GrowableArray ga = new GrowableArray();
ga.pushBack(4);
ga.pushBack(38);
int tmp = ga.popBack();
Thanks.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The J2SE Collections accept only Objects, as you've pointed out. I have noticed third party, open source, free Collections that work with primitives. You might want to try a quick search on Google. You could always write your own primitive Collection without too much work.
In the future, with Java 1.5, the compiler will autobox and unbox primitives as necessary. So, you'll be able to say myArrayList.add(13), and the compiler will step in and rewrite the code as myArrayList.add(new Integer(13)), saving us programmers some steps.
[ July 11, 2003: Message edited by: Dirk Schreckmann ]
 
Pin Ting
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a good news. I'm looking forward to coding with JSDK 1.5!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic