gpt4 book ai didi

java - 为什么我用这个程序得到非法的开始类型?我刚刚开始,但不知道哪里出错了

转载 作者:行者123 更新时间:2023-12-01 14:05:35 28 4
gpt4 key购买 nike

//NEX GUI
import javax.swing.JFrame;
public class NEX { extends JFrame

private static final int WIDTH =500;
private static final int HEIGHT =175;

public NEX()
{
setTitle("New Customer"); //sets the title of the frame
setSize(Width,Height);
}


/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JFrame aNEX =new NEX();
aNEX.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
aNEX.setVisible(true); //display the frame
// TODO code application logic here
}
}

最佳答案

代码

public class NEX {extends JFrame

应该是

public class NEX extends JFrame {

因为您使用的是 Java。

此外,正如 Joop Eggen 所指出的,代码 setSize(Width,Height); 应该是 setSize(WIDTH,HEIGHT); 因为您在使用时全部大写你声明了它们。

关于java - 为什么我用这个程序得到非法的开始类型?我刚刚开始,但不知道哪里出错了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18937166/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com