joe dacoolguy
joe dacoolguy

Reputation: 309

What am I doing wrong with this boolean?

boolean remindertextup = false;
remindertextup = text.contains("Unavailable");
if (value.contains("yes") && (remindertextup = true)){
    //statement
}

But the if statement still works if text does not contain unavailable and value contains yes.

What am am I doing wrong?

Thank you.

P.S.: Eclipse shows the boolean remindertextup to be never used.

Upvotes: 1

Views: 66

Answers (2)

Thanushan
Thanushan

Reputation: 532

In Java (like C and C++) '=' is an assignment. Try

if (value.contains("yes") && (remindertextup == true))
{
}

Upvotes: 0

John
John

Reputation: 16007

What you wrote in the if clause sets remindertextup to true. Change it to:

(remindertextup == true)

Upvotes: 4

Related Questions