在编译如下代码时:
package java.generic;
public class GenericMain
{
public static void main(String[] args)
{
GenericDemo<Integer> foo = new GenericDemo<Integer>();
foo.setFoo1(new Integer(1));
foo.setFoo2(new Integer(2));
System.out.println(foo.getFoo1());
System.out.println(foo.getFoo2());
}
}
提示java错误:
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.generic
问题所在:package java.generic;
定义包时不能以java.的形式定义
修改:package java1.generic;结果运行正常