Sorry ... but while
+
does what you say,
most Java programmers are not aware of this clever trick. The more idiomatic way to write this in Java is to call
equals
explicitly. (Hint: I'd give this "trick" a red-mark if I encountered it in a code review.) —
Stephen C 51 secs ago