我有以下代码,我在这一行得到空指针异常:unWanted[g].equals("")
我不知道这是怎么回事,因为我在此之前检查了 unWanted 是否为空。感谢您的帮助:)
public String[] setExercies(){
DataBaseMain data = new DataBaseMain(this);
data.open();
String[] unWanted = data.getAllUnwantedExercies();
String[] exits = data.getAllExercies();
data.close();
if(unWanted == null)
return exits;
int f = 0;
for(int g = 0; g < unWanted.length; g++)
{
if(unWanted[g].equals(""))
f++;
}
String[] temp = new String[unWanted.length-f];
f = 0;
for (int k = 0; k < unWanted.length; k++){
if(unWanted[k].equals("") == false)
{
temp[f] = unWanted[k];
f++;
}
}