Why using == to compare 2 int in the stack would return false but using >,< is fine?
import java.util.*;
class Solution {
public static void main(String[] args) {
Stack<Integer> a = new Stack<>();
Stack<Integer> b = new Stack<>();
Stack<Integer> c = new Stack<>();
a.push(1026);
b.push(1024);
c.push(1026);
System.out.println(a.peek());
System.out.println(b.peek());
System.out.println(c.peek());
if (a.peek() > (b.peek())) {
System.out.println(true);
}else
System.out.println(false);
if (a.peek() == (c.peek())) {
System.out.println(true);
}else
System.out.println(false);
if (a.peek().equals(c.peek()) ) {
System.out.println(true);
}else
System.out.println(false);
}
}
1026
1024
1026
true
false
true