Jim Moonves said:
I wonder if 1.5 will change that as primitive to
associated Object conversions are transparent?
Not as your subject indicates, but it will help.
Lets assume you want to use an ArrayList to store numbers of type "int",
well that's not possible, but if you use the wrapper Integer to instantiate
the ArrayList, you can use them in a similar manner, e.g.:
ArrayList<Integer> array = new ArrayList<Integer>();
array.add(1);
array.add(3);
If you now want to turn them back to an array of "int:s", you still have to
use the Integer-type:
Integer[] vektor = (Integer[]) array.toArray(new Integer[0]);
Since the *object* returned by toArray is an object of *array-type*, there
can't be any "unboxing" to e.g. an int[]. However, this is not really
necessary in most cases, since you now can use an Integer-object "almost" as
it would have been an int:
int sum = 0;
for (Integer temp : vektor)
{
sum = sum + temp;
}
System.out.println(sum);
// Bjorn A