This question already has an answer here:
- How to check for null value in java 4 answers
I think my question is different from the other questions like this because I have a problem with my logic. I am new to Java and so don't know if I have some logical errors.
Here is my code:
for(int i=0;i<10;i++){
if(!monday[i].equals(null)){
//my code goes here
} if(!tuesday[i].equals(null)){
//my code goes here
}
.
.
.
if(!sunday[i].equals(null)){
//my code goes here
}
}
I am trying to run the program but each time I get java.lang.NullPointerException.
Inside the if statement, the code is .executeUpdate() for an SQL database. I want to execute the update only if the contains data. Here is a side question: If I try to execute updates which won't work, will it corrupt or affect my data in the SQL table?
The if statements go from arrays of Monday to Sunday. Can anyone tell me how to solve my problem?
Aucun commentaire:
Enregistrer un commentaire