【发布时间】:2011-07-09 09:13:56
【问题描述】:
当我运行此代码时,字符串到 int 的转换会打印出 NULL 吗?当我打印出字符串时,它给了我一个字符串编号,但是当我尝试将该字符串转换为 int 时,它显示为 null,这是为什么呢?
for(int j = 0; j < removetrack.size(); j++){
String removetrackArray[] = removetrack.get(j).split(" ");
String candidateBefore = "";
int removetracklocation = Arrays.asList(removetrackArray).indexOf(past)-1;
if(removetracklocation != 1) {
String candidateBefore = "";
System.out.println(removetrack.get(j)+" location = "+ removetracklocation +" "+
(past)+" candidate name "+dictionary.get(votedfor) );
candidateBefore= Arrays.asList(removetrackArray).get(removetracklocation+1);
System.out.println(" this is a string "+candidateBefore);
System.out.println( Integer.getInteger(candidateBefore));
}
}
【问题讨论】: