java内部类的调用方式


public class DotThis {
public class Inner{
public DotThis outer(){
return DotThis.this;
};
}
/*
1.第一种 必须创建获取内部类的方法
public Inner inner(){
return new Inner();
}*/

public static void main(String[] args) {
//DotThis dt = new DotThis();
//DotThis.Inner dti=dt.inner();

//2.第二种直接就能获取到
DotThis dotThis = new DotThis();
Inner inner = dotThis.new Inner();
}
}
posted @ 2019-02-15 21:42  三号小玩家  阅读(8184)  评论(0编辑  收藏  举报
Title
三号小玩家的 Mail: 17612457115@163.com, 联系QQ: 1359720840 微信: QQ1359720840