File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Adding primitives to Lists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Adding primitives to Lists" Watch "Adding primitives to Lists" New topic
Author

Adding primitives to Lists

Tony Bateman
Ranch Hand

Joined: Mar 21, 2005
Posts: 42
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

Joined: Feb 07, 2005
Posts: 2367
You can wrap each integer in an Integer.
Tony Bateman
Ranch Hand

Joined: Mar 21, 2005
Posts: 42
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.
 
Consider Paul's rocket mass heater.
 
subject: Adding primitives to Lists