Stack pop comparison with equals operator

24 views Asked by At

Please help me to understand why the result of system.out.println is false.

public class Main {
    public static void main(String[] args) {

        Stack<Integer> s1 = new Stack();
        Stack<Integer> s2 = new Stack();

        s1.push(200);
        s2.push(200);

        System.out.println(s1.pop() == s2.pop());
    }
}

Tried debugging this but it didn't help. If I store the values in integer and compare it works fine.

0

There are 0 answers