当前位置: 代码迷 >> J2SE >> 字符串转换成整数数组有关问题
  详细解决方案

字符串转换成整数数组有关问题

热度:891   发布时间:2013-02-25 00:00:00.0
字符串转换成整数数组问题
现有String s = "1 2 3 4 11 22 33 44";

请问如何将其转换成整数数组?字符串里的数字是用空格分隔的。

------解决方案--------------------------------------------------------
String s = "1 2 3 4 11 22 33 44";
String[] x=s.split(" ");
int[] m=new int[x.length];
for(int i=0;i<x.length;i++){
m[i]=Integer.parseInt(x[i]);
}
这样试试
  相关解决方案