You should first split the String with the method split()
, and afterwards convert the strings into integers.
String str = "1,2,3,4";
String strs[] = str.split(",");
int ints[] = new int[strs.length];
for (int i = 0; i < strs.length; i++)
ints[i] = Integer.parseInt(strs[i]);
0
solved String To int [] in java [closed]