I know that when comparing String
s, you should use .equals()
not ==
and I understand the reasons for this. However I do sometimes forget and compare strings with ==
by mistake. I would like it if Eclipse (being much smarter than me), would warn me by doing one or more of the following:
- Underlining my mistake with a wiggly red line and pointing out the mistake
- Refusing to compile my code until I fix the mistake
- Fixing the mistake for me
- Beating me over the head with the nearest Joshua Bloch book until I apologize
In Eclipse 3.5, you can have Eclipse warn you about all kinds of things, by going to Window > Preferences > Compiler > Errors/Warnings, but sadly "Comparing strings with == instead of .equals()" does not seem to be one of them. Am I just missing it? Is there any chance of adding this in a future release?
EDIT: I'd rather do this using Eclipse's built-in functionality, rather than have to download a plugin. However, I think it would still be useful to mention plugins that have this feature in your answers.