aspose file tools*
The moose likes Beginning Java and the fly likes Java doesn't provide any API to directly cast int[] to Integer[] ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java doesn Watch "Java doesn New topic
Author

Java doesn't provide any API to directly cast int[] to Integer[] ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Java doesn't provide any API to directly cast int[] to Integer[] ?

Thanks.
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
No.

you have to go around using collection classes.


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Edward:

Why would you need to do that anyway, since autoboxing should take care of the individual elements?

John.
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

See Apache ArrayUtils.
The method toObject(int[] array) work for you. Hope it helps.


http://muhammadkhojaye.blogspot.com/
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Siva Masilamani wrote:you have to go around using collection classes.

Not really; the following code will do exactly the same as the ArrayUtils method Muhammed mentioned, and is not using collection classes:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Yes.Thats cool.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java doesn't provide any API to directly cast int[] to Integer[] ?