我有以下代码:
enum CarEnum {
BMW("BMW"), TOYOTA("Toyota"), FORD("Ford");
String name;
CarEnum(String s) {
name = s;
}
}
class Cars {
static CarEnum a;
public static void main(String[] args) {
System.out.println(a.BMW.name + " " + a.FORD.name);
}
}
它在一个名为 Cars.java 的文件中
当我尝试运行它时,我收到以下错误:
java.lang.NoClassDefFoundError: Car
Caused by: java.lang.ClassNotFoundException: Car
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
为什么说找不到类 Car?