Reputation: 24316
Given the following function:
public void convertToWrapper(long[] longsToConvert)
{
}
and
public void convertToPrimitive(Long[] longsToConvert)
{
}
Apache ArrayUtils exposes the following:
public Long[] toObject(long[] longs){
final Long [] result = new Long [array.length];
for (int i = 0; i < array.length; i++) {
result[i] = new Long (array[i]);
}
}
My question is there a way to do this utilizing only one array? I have tried the following which does not work:
for(int i =0;i<array.length;i++)
{
array[i] = new Long(array[i]);
}
Upvotes: 0
Views: 73
Reputation: 14225
No. A Long[]
is not the same type as a long[]
, so assignment will fail.
Upvotes: 5