shouldn't this be, 11 is good and 21 is bad? because, in case of i++, the value 10 first gets evaluated if equal to i, and then incremented?
int i = 10;
if(i++ == i){
System.out.println(i + " is good");
}
else{
System.out.println(i + " is bad");
}
int j = 20;
if(++j == j){
System.out.println(j + " is good");
}
else{
System.out.println(j + " is bad");
}
Output: 11 is bad 21 is good
Aucun commentaire:
Enregistrer un commentaire