質問

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]);
}  
役に立ちましたか?

解決

No. A Long[] is not the same type as a long[], so assignment will fail.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top