if(mail.equals(usermail) && date1.equals(date) && title1.equals(title))
            {
                System.out.println("record is matched");
                returnFlag = true;
                break;

         }

the if statement is not executing even though all the strings are equals.

Recommended Answers

All 5 Replies

If the "if statement is not executing", then either it is not being called or the values are not equal. Those are the only possibilites (considering the posted code).

but the values are equal then, what may be the reason that if statement is not executing

Because you're not calling it? Because the execution block never reaches the if statement? (I am talking about the if statement, not the code block associated with.)

Right before you call the if statement, why don't you try printing out the value of each of those equals() method calls and tell us what it says.

System.out.println(mail.equals(usermail)); 
System.out.println(date1.equals(date)); 
System.out.println(title1.equals(title));

start quote:

         if(mail.equals(usermail) && date1.equals(date) && title1.equals(title))
            {
                System.out.println("record is matched");
                returnFlag = true;
                break;

         }

the if statement is not executing even though all the strings are equals.

As BestJewSinceJC, suggested you can try to print each of the values or you can add a logger to identify if control is entering the loop and displaying logger.info(""). Let us know if you are not familiar with this and we can help.

Cheers,
Adi

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.