Forums Register Login

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

+Pie Number of slices to send: Send
Java doesn't provide any API to directly cast int[] to Integer[] ?

Thanks.
+Pie Number of slices to send: Send
No.

you have to go around using collection classes.
+Pie Number of slices to send: Send
Edward:

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

John.
+Pie Number of slices to send: Send
See Apache ArrayUtils.
The method toObject(int[] array) work for you. Hope it helps.
+Pie Number of slices to send: Send
 

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:
+Pie Number of slices to send: Send
Yes.Thats cool.
This is my favorite tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1154 times.
Similar Threads
Question about int... and Integer from Java Inquisition
Variable Madness
Putting digits one by one
Converting int to String
Widening & Boxing
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:14:32.