为什么我的数组包含所有空值? [英] Why does my array contain all nulls?
本文介绍了为什么我的数组包含所有空值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我的数组包含所有空值?
System.out.println(loo); - >这将正确显示数组中的内容
System.out.println(tokFix [i]); - >虽然这将显示所有null的
Why does my array contain all nulls?
System.out.println(loo); -> This will show what's inside the array properly
System.out.println(tokFix[i]); -> While this will show all null's
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++;
<big>System.out.println(loo);
System.out.println(tokFix[i]); </big> }
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;
}
推荐答案
你增加 i
之前检查。当然下一个项目是空的,你还没有填充它。
You incremented i
before checking. Of course the next item is empty, you haven't populated it yet.
这篇关于为什么我的数组包含所有空值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文