AbAppletic AbAppletic - 1 year ago 132
Java Question

Why does Android Studio warn me about a Boolean parameter always being false?

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. So can I remove this warning without having to disable the complete warning in settings since it will be useful in helping me kill bugs in the future?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download