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? -

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

ajax - PHP/JSON Login script (Twitter style) not setting sessions -