-2

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.

Tulains Córdova
39.6k13 gold badges102 silver badges157 bronze badges
asked Dec 15, 2016 at 8:27
2

1 Answer 1

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.

answered Dec 15, 2016 at 8:59
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.