@Override注释出现问题

fir*_*w52 2 java overriding

我正在创建一个类似于Banko applet的Java应用程序.当我点击"public void init()"方法时,我的表现很好.当我完成时,除了那之外所有编译.它告诉我添加@Override注释.我试过了,但每当我这样做,无论我把它放在哪里,编译器都会失败并出现以下错误:

找不到标志

符号:类覆盖

location:class aBomb.Bomb

我不知道是什么阻止了应用程序正常执行.:| 如果您在下面写的代码中找到了您认为应该更改的内容,请告诉我.我是Java的新手:(代码:

public void init() {
    BorderLayout border = new BorderLayout();
    setLayout(border);

    JPanel top = new JPanel();
    JLabel moneyLabel = new JLabel("Money : $");
    moneyField = new JTextField("", 8);
    moneyField.setEditable(false);
    JLabel foundLabel = new JLabel("Found: ");
    foundField = new JTextField("", 8);
    foundField.setEditable(false);

    restart = new JButton("Restart");
    restart.addActionListener(this);
    top.add(moneyLabel);
    top.add(moneyField);
    top.add(foundLabel);
    top.add(foundField);
    top.add(restart);
    add(top, BorderLayout.NORTH);

    board = new Board(this, ROW_COUNT, COLUMN_COUNT, BOMB_COUNT);
    add(board, BorderLayout.CENTER);
    setup();
    setVisible(true);
}
Run Code Online (Sandbox Code Playgroud)

Dan*_*lau 7

首先,如果您至少包含了类定义("公共类......"部分),那将会非常有用.

我猜你有一个名为aBomb的类,它从Applet扩展而来:

public class aBomb extends Applet {
//...
    // Here's the init method; the @Override goes
    // immediately before the declaration.
    @Override
    public void init() {
//...
};
Run Code Online (Sandbox Code Playgroud)

错误消息看起来像拼写错误@Override一样@Overrides.