I heard several times that in using boolean equals(Object o)
to compare Strings
, it's better to put the constant on the left side of the function as in the following:
- Bad: myString.equals("aString");
- Good: "aString".equals(myString);
Why is this?
See Question&Answers more detail:os