I'm curious as to why the following line works fine in IntelliJ but is shown as an error in Eclipse (both using Java 7):
return toolbar.getClientProperty("PrototypeToolbar") == true;
I saw this code as part of our project and at first I did not think it would work because getClientProperty()
returns an Object
and we are comparing it to a boolean
. However, for those of us that use IntelliJ, it works fine but for others on the team that are using Eclipse, it shows as an error.
My guess is that it can technically work because 0 == false
and it could be that anything not 0 == true
. However, I'm not sure why one IDE complains and the other does not. Which one is 'right'?
Note: The above line was used to find a toolbar that was part of an old framework and difficult to access. This check was used to filter and find the PrototypeToolbar
. I've already suggested to change this from just simply checking if it's true to checking the type using instanceof
.
Thanks!