jeudi 6 avril 2017

error: 'else' without 'if'

I've searched this on Google before coming here, and the common mistakes people made were adding ";" accidentally, or not understanding what an if-statement does. All the variable in the code are declared (the actual code is super long), and my if statement follows the correct if-statement conditioning format. Why am i still getting this error?

for(int k= 0; k < answer.length; k++){
if(answer[k].charAt(0) == a || b || c || d ||){
   answer[k]= answer[k] + "correct";
}
else{
 answer[k]= answer[k] + "wrong";
}
}

Updated code (Still getting the erro):

for(int k= 0; k < answer.length; k++){
    if(answer[k].charAt(0) == a || b || c || d){
       answer[k]= answer[k] + "correct";
    }
    else{
     answer[k]= answer[k] + "wrong";
    }
    }

Aucun commentaire:

Enregistrer un commentaire