为什么我的数组包含所有空值?在这个代码区域
while (st.hasMoreTokens()) {
tokFix[i] = st.nextToken();
String loo = tokFix[i];
i++;
System.out.println(loo);
System.out.println(tokFix[i]); }
当我做
System.out.println(loo);
它将正确输出数组中包含的每个字符串值
但是,当我做 S
System.out.println(tokFix[i]);
它只会给我所有空值的输出
导致这种事情发生的两者有什么区别?
代码:
public static String[] parseFixMsg(String fixMsg1,String fixMsg2){
int i = 0;
int size = getArraySize(fixMsg1);
String[] tokFix = new String[size];
StringTokenizer st = new StringTokenizer(fixMsg2,(Character.toString((char)01))+"]");
st.nextToken();
while (st.hasMoreTokens()) {
tokFix[i] = st.nextToken();
String loo = tokFix[i];
i++;
System.out.println(loo);
System.out.println(tokFix[i]); }
return tokFix;
}
public static int getArraySize(String fixMsg){
int size = 1;
StringTokenizer st = new StringTokenizer(fixMsg,(Character.toString((char)01))+"]");
st.nextToken();
while (st.hasMoreTokens()) {
st.nextToken();
size+=1;
}
return size;
}