You are comparing links, so it is better to use int. Never use "==" to compare Integer objects (or Float, Double, Short, Character, Byte, Long, BigDecimal ...) for equality. Compare the numbers in their primitive form - i.e. Work with int, short, long, double.
If you want to compare integers, use the compareTo () method.
Milos source share