I have a question about the object X.equals(Y).

I use Sonar and it says that I have to move the "" string literal on the left side of this string comparison: !date.equals("").

So I did that: !("").equals(date) but I don't really know if it is right or not.


1 Answer 1


!"".equals(date) and !("").equals(date) and !(("")).equals(date) and !(((""))).equals(date) and !("".equals(date)) all return the same thing.

So you correctly switched the string literal with the variable, you just added some not needed parentheses.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.