Code example for EmptyStackException

0
            throw new IllegalArgumentException("Неверный формат строки");
        } 
 
        if (stack.size() < 2)
        { 
            throw new EmptyStackException();
        } 
 
        Double num2 = stack.pop();
        Double num1 = stack.pop();
        stack.push(getResult(num1, num2));
    } 
 
    protected abstract double getResult(double num1, double num2);
}