AbAppletic AbAppletic - 3 months ago 8x
Android Question

Why isn't the compiler noticing that a boolean has been declared true?

Take a look at my code below:

private void implementVisibility(EditText A, EditText B, ImageButton C, boolean visible) {
if (visible) {
else if(!visible){



At the line
else if(!visible)
I get the warning: "
Condition !visible is always true
" and "
Value visible is always false
". But if you take a look at my previous method:

if (count2.getVisibility() == View.INVISIBLE) {
implementVisibility(count2, action2, remove2,true);

" is
, therefor, it isn't always false. Why isn't the compiler noticing that it isn't ALWAYS false?

Note: Please don't downvote just because this question is heavily downvoted. This question has been edited and improved. Thank you.


By the time program control gets to else if(!visible){, visible can only be false.

Your compiler is hinting that you should clarify your code to else { instead.