今天想把内部类封装起来,然后提供给其他类使用,但是出现这样的编译错误,No enclosing instance of type PrintUtil is accessible. Must qualify the allocation with an enclosing instance of type PrintUtil (e.g. x.new A() where x is an instance of PrintUtil).
结果想起来了,内部类实例化的时候要先实例化外部类,然后再使用,类似下面这样就解决了
1.Inner i = new A().new Inner();
2. A a=new A();
3. MyThread m = a.new MyThread(i, 3000);
4. a.new MyThread(i, 3000).start();
5. a.new MyThread(i, 1000).start();