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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -