I want to add multiple conditions to a breakpoint in IntelliJ. Something like:
stringA.equals("test") && objectA.equals(objectB);
How can I do this?
IntelliJ IDEA breakpoint condition can be any boolean expression:
Select to specify a condition for hitting a breakpoint. A condition is a Java Boolean expression including a method returning true or false, for example, str1.equals(str2).
This expression must be valid at the line where the breakpoint is set, and it is evaluated each time the breakpoint is hit. If the evaluation result is true, the selected actions are performed.
You can enter multi-line expressions, for example:
if (myvar == expectedVariable) { System.out.println(myvar); anotherVariable = true; } return true;
stringA.equals("test") && objectA.equals(objectB) appears to be a valid expression returning true or false, so it should work right out of the box.
Proof of work:


The following condition statement will also work:
return stringA.equals("test") && objectA.equals(objectB);
Please note that there is a known issue which will show a red underline after the condition indicating that semicolon is expected. If you add the semicolon, the condition will become invalid and you will have to also add a return statement to make it valid again. It's a cosmetic issue and you can either use the condition without semicolon and ignore the error or you can add the semicolon and return to make it a valid statement:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With