Return an array by converting from an ArrayList in Java -
i need create method return int array casting arraylist. here code:
public int[] getdestsets() { int[] array = new int[destset.size()]; destset.toarray(array); return array; }
destset integer arraylist. got error "the method toarray(t[]) in type arraylist not applicable arguments (int[])". can give me hint? thanks!
you can try use arrayutils class apache commons lang library. need 2 steps. first convert arraylist wrapper object array (integer[]). after can use arrayutils.toprimitive() convert array of int (int[]).
Comments
Post a Comment