亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - 數(shù)組溢出問題,在自己電腦上面不報錯,在別人電腦上面報錯
怪我咯
怪我咯 2017-04-18 10:53:20
0
4
573

我將每條數(shù)據(jù)進行分割,之后在我的電腦上面運行沒有問題,但是把代碼遷移到別人的電腦上面就報了數(shù)組溢出的 問題。我要進行分割的是這樣的數(shù)據(jù):nf-000001。以中間的"-"作為分割的界限,把數(shù)據(jù)分成"nf"和"000001"。
代碼

for(int i=1;i<rsRows;i++){
                String originNum=null;
                Cell cell=readsheet.getCell(column,i);
                originNum=cell.getContents();//獲得數(shù)據(jù)“nf-000001”
                String[] numGoods=originNum.split("-");//數(shù)據(jù)進行分割
                list.add(numGoods[1]);//講分割的后半部分添加在一個Array<String> list中
            }

錯誤提示:圖片中160行就是報的list.add(numGoods[1])這個語句的錯誤,我看他說是數(shù)組溢出,然而在我的電腦上面沒有出現(xiàn)這個問題,很奇怪,求大神相助!!

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(4)
小葫蘆

Set a breakpoint. You will know during debugging that the array is out of bounds. Before printing rsRows里面是否有沒有-的情況,你在numGoods[1], you should at least check the length of the array for the sake of code robustness.

巴扎黑

Too little relevant information given...

巴扎黑

After splitting, judge the length of the numGoods array. It may be that the length of the numGoods element group is less than 2.

小葫蘆

I guess the string entered on this computer is not a string connected by "-".
You need to see the - symbol clearly. There are shorter ones and longer ones. Make sure you input it correctly

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template