Java Learning Note – inner class(2)

      Java Learning Note – inner class(2)

Reference: Java Tutorial (Oracle)

 

 

 

Meaning

Characters

 

Inner

class

 

 

help the outer class to realize some function

(ex. iterator of Array)

 

1.inner class can be viewed as a member of an instance outer class, hence, it must depend on an instance. (no static allowed)

 

2.inner class method with be covered by the outer class same name method.

(use this.field  to access inner class members, and OuterClass.this.field to access outer class members)

 

3.it can realize a interface, the outer class return such an interface.(???)

 

Static inner class

same as static class member

1.it can only access static outer member

 

2. have no illustration to outer class

 

Local inner class

class in a block

 

1.it can access final variables in the method where it was stated

( because local inner class will die when the method finished)

Anonymous inner class

 

1. used when an instance of class is needed

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值