String model;
int year;
enum Color {GREEN, BLUE, RED};
double price;
颜色色调;将ENUM类型指定给构造函数
public Car(String model, int year, Color shade, double price) {
this.model = model;
this.year = year;
this.shade= shade;
this.price = price;
}
可以这样做吗?当我用主要方法实际制作对象时仍然出现错误。
不,你没有。这不知道枚举的工作。你已经声明了一个类型,你没有定义一个实例。 – Ivan
嘿,那我该怎么做? –