package sableCCCalculator; import sableCCCalculator.types.*; import java.util.Stack; public class ProgramStack extends Stack { public String toString() { String out = "Stack is now: ["; for (int i = 0; i < this.size(); i++) { // String theStr = this.elementAt(i).toString(); // out += String.format("%s, ", theStr.substring(0, theStr.length() - 1)); out += String.format("%s, ", this.elementAt(i).toString()); } return out.substring(0, out.length() - 2) + "]"; } public static void main(String[] args) { ProgramStack myStack = new ProgramStack<>(); myStack.add(new Int(2)); myStack.add(new Int(4)); myStack.add(new Int(6)); myStack.add(new Int(0)); myStack.add(new Int(1)); myStack.add(new Decimal(24601.10642)); System.out.println(myStack.pop().getText()); System.out.println(myStack); } }