在另一个文件中找不到 class

Cannot find class in another file

我查看了其他用户针对类似问题提出的答案,但仍然无法弄清楚为什么我创建的两个 类 出现找不到符号错误。

我的目录看起来像这样

StacksAndQueuesProblems/threestacks

threestacks 目录中,我有以下 .java 个文件:

FullStackException.java
fixedMultiStack.java

我试图从 StacksAndQueuesProblems 目录执行 javac threestacks/*.java 但是我收到以下错误:

    threestacks/fixedMultiStack.java:20: error: cannot find symbol
            throw FullStackException("ERR: That stack is full!");
                  ^

FullStackException.java

package threestacks;

public class FullStackException extends Exception {

    public FullStackException(String message) {
        super(message);
    }
}

fixedMultiStack.java

package threestacks;

class fixedMultiStack {

    private int numberOfStacks = 3;
    private int stackCapacity;
    private int[] values;
    private int[] sizes;

    public fixedMultiStack(int stackCapacity) {
        this.stackCapacity = stackCapacity;
        values = new int[stackCapacity * numberOfStacks]; // Holds all 3 stacks
        sizes = new int[numberOfStacks+1]; // Holds the number of items in each stack
    }

    /* push value onto stack */
    public void push(int stackNum, int value) throws FullStackException {
        /* check if we have space on the stack for the element */
        if (isFull(stackNum)) {
            throw FullStackException("ERR: That stack is full!");
        }
        /* increment stack pointer and then insert the value */
        sizes[stackNum]++; // Increment the number of items for that stack
        values[indexOfTop(stackNum)] = value; // Insert the value into the array
    }

    /* Pop item from the stack */
    public void pop(int stackNum) {
        if (isEmpty(stackNum)) {
            throw new EmptyStackException();
        }
        /* Retreive the value and decrement the stack pointer */
        int topIndex = indexOfTop(stackNum);
        int value = values[topIndex]; //Get top
        values[topIndex] = 0; // Clear
        sizes[stackNum]--; // Decrement the size of the stack
    }

    /* Return top element */
    public int peek(int stackNum) {
        if (isEmpty(stackNum)) {
            throw new EmptyStackException();
        }
        int topIndex = indexOfTop(stackNum);
        int value = values[topIndex];
        return value;
    }

    /* Return if stack is empty */
    public boolean isEmpty(int stackNum) {
        return sizes[stackNum] == 0;
    }

    /* Return if stack is full */
    public boolean isFull(int stackNum) {
        return sizes[stackNum] == stackCapacity;
    }

    /* Returns index of top of stack */
    public int indexOfTop(int stackNum) {
        return ((stackNum -1) * stackCapacity + sizes[stackNum] - 1);
    }
}

文件 fixedMultiStack.java 中存在编译错误。应该是

throw new FullStackException("ERR: That stack is full!");