所以我正在开发一个程序,它将以字符串 EG 的形式读取数学方程:1 + 2 * 3
我需要有两个不同的堆栈,一个用于数字,另一个用于操作数。将数字压入数字堆栈并将运算符压入字符堆栈,然后在满足某些条件时处理等式。我们正在使用我已导入环境的 ArrayStacks。但是,在尝试编译堆栈时,我不断收到错误消息。
这是我所拥有的:
public static String test = new String("2 * 3 + 6 ");
public static ArrayStack<Double> numbers = new ArrayStack<Double>[20];
public static ArrayStack<Character> operands = new ArrayStack<Character>[20];
它一直给我这个错误(用-Xlint运行):
infixNotation.java:7: error: generic array creation
public static ArrayStack<Double> numbers = new ArrayStack<Double>[20];
^
infixNotation.java:8: error: generic array creation
public static ArrayStack<Character> operands = new ArrayStack<Character>[20];
^
/home/tyler/CSC223/bookFiles/ch03/stacks/ArrayStack.java:22: warning: [unchecked] unchecked cast
stack = (T[]) new Object[DEFCAP];
^
required: T[]
found: Object[]
where T is a type-variable:
T extends Object declared in class ArrayStack
/home/tyler/CSC223/bookFiles/ch03/stacks/ArrayStack.java:27: warning: [unchecked] unchecked cast
stack = (T[]) new Object[maxSize];
^
required: T[]
found: Object[]
where T is a type-variable:
T extends Object declared in class ArrayStack
/home/tyler/CSC223/bookFiles/ch03/stacks/StackOverflowException.java:3: warning: [serial] serializable class StackOverflowException has no definition of serialVersionUID
public class StackOverflowException extends RuntimeException
^
2 errors
3 warnings