| Author |
casting into primitive wrapper class
|
Jan Groth
Ranch Hand
Joined: Feb 03, 2004
Posts: 456
|
|
hi there, playing with the Collection Framework, I was wondering about the following issue: What is the most efficient way (or: _any_ way but a loop) to cast a array of primitives int myArray[] = {1,2,3,4,5} into a array of Integer wrapper objects? My goal was to be able to handle myArray[] as a Collection. Arrays.asList(Object[] a) looked like a appropriate method to me. But, as already quoted, I had to cast it manually to a help-array Integer myHelpArray[] which worked out, but doesn't look too efficient to me ;-) thanks for any help, Jan
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Welcome to JavaRanch, Jan! We beginners aren't too interested in alleged efficiencies, especially as premature optimization is the root of all evil [Knuth]. We're more concerned with clarity of code. Moving this to the Performance forum... [ February 03, 2004: Message edited by: Dirk Schreckmann ]
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
 |
|
|
subject: casting into primitive wrapper class
|
|
|