1,非静态内部类持有外部类引用,但是非静态内部类的内部接口的实现类对象持有最外层类的引用么?
Handler myHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case TestHandler.GUIUPDATEIDENTIFIER:
myBounceView.invalidate();
break;
}
super.handleMessage(msg);
}
};
2,再说几个语法
package com.example.autoinstall;
public class TestDemo317 {
// 内部接口里面还可以写接口
interface Intf0 {
public interface Intf0Sub0 {
void test();
}
}
// 非静态内部类里面不可以写接口
class Class0 {
interface Class0InnerIntf {// The member interface Tof1 can only be
// defined inside a top-level class or
// interface
void test();
}
}
// 静态内部类里面可以写接口
static class Class1 {
public interface InnerIntf1 {
void test();
}
}
// 内部接口里面的接口中可以再嵌套一个接口
interface Intf2 {
public interface InnerIntf1 {
public interface InnerIntf2 {
void test();
}
void test();
}
}
interface Intf3 {
public interface InnerIntf1 {
public interface InnerIntf1 {// public interface不能和上级同名,The nested
// type InnerIntf1 cannot hide an
// enclosing type
void test();
}
void test();
}
}
interface Intf4 {
public interface InnerIntf1 {
interface InnerIntf1 {// interface不能和上级同名,The nested type InnerIntf1
// cannot hide an enclosing type
void test();
}
void test();
}
}
// 非静态内部类里面还可以写非静态内部类
class Class3 {
class Class4 {
}
}
class Class4 {
class Class4 {// 不能和上级同名,The nested type Class4 cannot hide an enclosing
// type
}
}
// 静态内部类里面还可以写非静态内部类
static class Class5 {
class Class6 {
}
}
// 静态内部类里面还可以写静态内部类
static class Class6 {
static class Class7 {
}
}
// 非静态内部类里面不可以写静态内部类
class Class7 {
static class Class8 {// The member type Tof8 cannot be declared static;
// static types can only be declared in static
// or top level types
}
}
}