import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class ExitOrNo
{
int life=100;
while(true){
life--;
if(life==1){
new ActionListener(){
public void actionPerformed(ActionEvent e){
int result=JOptionPane.showConfirmDialog(null,
"Exit game now?",
"please answer",
JOptionPane.YES_NO_OPTION);
if(result==JOptionPane.YES_OPTION){
System.exit(0);
}
if(result==JOptionPane.NO_OPTION){
System.out.println("kyo");
}
}
}
}
}
public static void main(String[] args)
{
new ExitOrNo();
}
}
错误如下:
---------- javac ----------
ExitOrNo.java:7: 非法的类型开始
while(true){
^
ExitOrNo.java:31: 需要 <标识符>
}
^
2 错误