我对 Java 很陌生,但我也很确定我在这里尝试做的事情不会干扰任何未来或过去的时间线,但 Eclipse 肯定不会让我超越这一点。我真的不明白为什么会发生这种情况或如何解决这个问题?
简单地说:我正在调用一个可以删除记录的函数/方法(如果按下按钮)。调用方法只是想知道用户是否删除(更改)了数据库?我用过这样的布尔值没有任何问题。我看过 lambda、final 等,但我的专业知识还不够,但同样,这是一项非常简单的任务。谢谢!
static Boolean EditRecord(int listboxIndex) {
Boolean dbgotAltered = false;
.
.
JButton button1 = new JButton("Delete");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dbData.remove(listboxIndex);
dbgotAltered = true;
// Local variable dbgotAltered defined in an
// enclosing scope must be final or effectively final
// Looking for a fix for dbgotAltered. The Calling
// procedure/method really wants to know?
}
});
.
.
return dbgotAltered;
}