Code example for Stack

Methods: clear, peek, pop, push, size

0
        } 
    } 
 
    private void doOpChar(char op) {
        if (isInEquals) {
            stack.clear();
            isInEquals = false;
        } 
        stack.push(result);
        doLastOp(); 
        lastOp = op;
        tvOp.setText(String.valueOf(lastOp));
    } 
 
    private void doLastOp() { 
        isRestart = true;
        if (lastOp == '\0' || stack.size() == 1) {
            return; 
        } 
 
        String valTwo = stack.pop();
        String valOne = stack.pop();
        switch (lastOp) {
            case '+': 
                stack.push(new BigDecimal(valOne).add(new BigDecimal(valTwo)).toPlainString());
                break; 
            case '-': 
                stack.push(new BigDecimal(valOne).subtract(new BigDecimal(valTwo)).toPlainString());
                break; 
            case '*': 
                stack.push(new BigDecimal(valOne).multiply(new BigDecimal(valTwo)).toPlainString());
                break; 
            case '/': 
                BigDecimal d2 = new BigDecimal(valTwo);
                if (d2.intValue() == 0) {
                    stack.push("0.0");
                } else { 
                    stack.push(new BigDecimal(valOne).divide(d2, 2, BigDecimal.ROUND_HALF_UP).toPlainString());
                } 
                break; 
            default: 
                break; 
        } 
        setDisplay(stack.peek());
        if (isInEquals) {
            stack.push(valTwo);
        } 
    } 
 
    private void doPercentChar() { 
        if (stack.size() == 0)