You appear to have arrived in the wrong forum, but don't worry; I can move your question.
Have a look at the documentation for the Integer#valueOf method, and the JLS (=Java® Language Specification) about boxing conversions. Look particularly at what it says about values ≥ −128 and ≤ 127. That should give you a hint why you are getting strange results from the == operator. Another reason not to use ==.
If you can't work out the problem from those resources, tell us, and we shall drop some more hints.
I was born with webbed fish toes. This tiny ad is my only friend: