所以我想编译这段代码,并得到:错误:变量笔记本电脑可能没有启动。Java //变量初始化错误
public class Computer{
String modelName;
String motherboard;
String systemType;
int ram;
int cpu
int hdd;
public static void main(String[] args){
Computer Laptop;
Laptop.modelName = "M610";
Laptop.motherboard = "MSI";
Laptop.systemType = "Linux";
Laptop.ram = 2048;
Laptop.hdd = 50;
Laptop.cpu = 1500;
System.out.println("Model name:"+Laptop.modelName);
System.out.println("Motherboard:"+Laptop.motherboard);
System.out.println("System type: "+Laptop.systemType);
System.out.println("RAM :"+Laptop.ram);
System.out.println("HDD:"+Laptop.hdd);
System.out.println("CPU :"+Laptop.cpu);
}
}
非常感谢您提前!
@Vladimir你实际上可以生成这个代码的一半:) - 大多数IDE可以选择从类中声明的字段生成Getters&Setters(以及其他东西) - 如果你发现我的答案足够好,随时可以接受它:) –
我的IDE是Linux终端和JAVAC =) – Vladimir