java - How to convert ArrayList<Integer> to an int[]? -
i have array saved in strings.xml.
want how many items there in list, , put in list.
for example, if string
contains {"one", "two", "three"}
,
want int
contains {0,1,2}
.
from know, way use arraylist
, use add
method.
here code i'm using make this:
string[] names; arraylist<integer> mylist; (int = 0; < names.length; i++){ mylist.add(i); }
but problem don't know how change arraylist<integer>
int[]
.
how can done?
if want create int[]
array of numbers 0 names.length
, how it:
int[] numbers = new int[names.length]; (int = 0; < names.length; i++) { numbers[i] = i; }
Comments
Post a Comment