我正在尝试将一串数字(例如“34 4 5 6 67 45 34”)转换为短裤数组。
我写了以下代码:
//Split the string and then build a short array with the values.
String[] tabOfShortString = finalString.split(" ");
int length = tabOfShortString.length;
System.out.println("Length of float string is" + length);
short[] shortsArray = new short[length];
for (int l = 0; l < length; l++) {
//System.out.println("l is currently "+l);
Short res = new Short(tabOfShortString[l]);
System.out.println("Indice Short Value is " + res);
shortsArray[l] = res;
}
问题是完成的数组(shortsArray)没有准确地捕获我的字符串。谁能发现可能出了什么问题?
谢谢你。