我有以下代码:
for (int i=0; i<wallMaterialName.size(); i++){
if (Math.abs(calculatedWallUValue - alternativeWallUValue) > 0.01){
if(wallMaterialName.get(i).charAt(0) == 'A'){ //*****ERROR IN HERE*****
PreparedStatement prepStateMat = con.prepareStatement("select * from concretestonefloor where value<? order by value desc limit 1");
prepStateMat.setFloat(1, (Float)wallMaterialLambda.get(i));
ResultSet rsMaterial = prepStateMat.executeQuery();
//...
}
//...
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,会出现"java.lang.NullPointerException".错误来自此代码:
if(wallMaterialName.get(i).charAt(0) == 'A')
Run Code Online (Sandbox Code Playgroud)
我不知道为什么arraylist是空的,因为我检查它包含一些数据.谁知道如何解决这个问题?谢谢.