本帖最后由 黑马张伟 于 2011-12-25 10:54 编辑
EnumTest类
package java;
public class EnumTest {
public static void main(String[] args) {
WeekDay weekDay = WeekDay.MON;
System.out.println(weekDay.nextDay());
}
}
WeekDay 类
package java;
public class WeekDay {
private WeekDay(){}
public final static WeekDay SUN = new WeekDay();
public final static WeekDay MON = new WeekDay();
public WeekDay nextDay()
{
if(this==SUN)
return MON;
else
return SUN;
}
public String toString()
{
return this==SUN?"SUM":"MON";
}
}
错误类型
java.lang.SecurityException: Prohibited package name: java
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main" |