Check if a stack of Integers contains a sequence of consecutive values
Bug 1

Stack&lt;Integer&gt; stack = new Stack&lt;&gt;();
stack.push(1);
stack.push(2);
stack.push(3);
System.out.println(isConsecutive(stack));


returns false.

Bug 2

Your method throws EmptyStackException on stack of size 1.

Advice

I suggest you declare your method as static. That way the client programmer does not need to instantiate an object.

Alternative implementation

This is just a slight modification of my answer to your previous stack related question:

public static boolean isConsecutiveV2(Stack&lt;Integer&gt; stack) {
    if (stack.size() &lt;= 1) {
        return true;
    }

    Stack&lt;Integer&gt; aux = new Stack&lt;&gt;();

    aux.push(stack.pop());

    while (!stack.isEmpty() &amp;&amp; stack.peek() == aux.peek() - 1) {
        aux.push(stack.pop());
    }

    boolean consecutive = stack.isEmpty();

    // Restore the input stack:
    while (!aux.isEmpty()) {
        stack.push(aux.pop());
    }

    return consecutive;
}