== compares references and equals() compares values. If you don't understand the difference between references and values, then learning that is your first job. While it's possible to code in
Java without clearly understanding references, I don't think it's really possible to do it well.
Somewhat complicating the issue is that the default implementation of equals() just compares references, so it does exactly what == does. However, Integers override that behavior, and instead compare the integer values, so even two Integer objects with different references will be equal according to equals() if they contain the same value.
Further complicating the issue is that Java's compiler tries to optimize memory usage. It will sometimes recognize that two Integers contain the same value and so can share a reference. In those cases, the ==
test will return true even though it seems you are comparing two different objects. It is because Integers are immutable that the compiler can safely make this optimization.