File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding primitives to Lists

 
Tony Bateman
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to create a list of integers as an ArrayList but I cannot because ArrayLists method add(Object o) expects an object and not a primitive.

How can I create simple, extensible arrays of integers?

Kind regards,

Tony.
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can wrap each integer in an Integer.
 
Tony Bateman
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for that; found it in "Sun Certified Programmer and Developer for Java 2" page 376.

Think I'll read the book to the end before posting again...

Cheers,

Tony.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic