| Author |
converting int array to List
|
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
How can I do that?
Of course that doesn't work properly, because: asList(T... a), and int is not T.
|
SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
List cannot contains primitive elements. I think the only option is to iterate over the array and add elements to the list...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Sebastian Janisch
Ranch Hand
Joined: Feb 23, 2009
Posts: 1183
|
|
This will work...
|
JDBCSupport - An easy to use, light-weight JDBC framework -
|
 |
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
OK, I knew that. So there is no way to convert int[] to list of Integers in one step.
By the way I have another question about generics.
How does compiler know that:
is:
|
 |
Sebastian Janisch
Ranch Hand
Joined: Feb 23, 2009
Posts: 1183
|
|
Check the implementation of the Arrays.asList class. Pretty straight forward.
|
 |
 |
|
|
subject: converting int array to List
|
|
|