我想在Java中将带有整数的字符串转换为带有整数的数组。我该怎么做?我有一个带有字符串的数组。每个字符串都是整数。我想通过单击按钮来访问每个字符串。
String[] INT_ARRAY={
//0
"250,125,20,20,20,40,20,20,20,40,20,20,20,2500",
//1
"233,63,28,63,29,63,28,16,28,17,26,63,29,17,26,16....
........
}
public void onClick(View v) {
counter++;
String IntString = INT_ARRAY[counter];
String[] parts = IntString.split(",");
final int[] A = new int[parts.length()];
for(int i=0; i<parts.length(); i++){
A[i] = Integer.parseInt(parts(i));
Toast.makeText(getApplicationContext(),String.valueOf(A[i]), Toast.LENGTH_SHORT).show();
}
}