jeudi 14 juillet 2016

Eclipse "The local variable b is never read" msg although i assign and use the boolean java variable? [duplicate]

This question already has an answer here:

When i try following java code
Assign false value to my boolean variable b and use it on if condition on the same statement
There is a message from eclipse IDE
Which hint me that "The local variable b is never read"

boolean b = false;
 if (b = false) { // boolean assignment & usage on one statement
    System.out.println("true");
}else {
    System.out.println("false");
}

Kindly show why this message appeared although i use my variable?
Note : if condition is that b==false the message will not be shown

Aucun commentaire:

Enregistrer un commentaire