This is not a duplicate question! I'm not comparing two Integers, but an Integer and an int value. Moreover, I'm asking for what people think about what I'm doing not to tell me how to properly compare...
I just want to know what do you think about comparing an object of type Integer with an int value like this :
final Integer i = null; //I'm setting it to null just to show that my test will not throw a NullPointerException, otherwise I could used a simple `int`
if (i == Integer.valueOf(3))
...
What I found useful with this is that there is no need to check if my object is null or not. Moreover Integer.valueOf()
caches Objects....