读书人

why can inner class be instantiated

发布时间: 2012-10-29 10:03:53 作者: rapoo

why can inner class be instantiated in this way?

public class Outer {    public void instantiated() {        Inner in = new Inner();    }    class Inner {        public void a() {        }    }}

?

class Inner can be instantiated in instance method, cuz before new Inner() is called, there must be an outer class instance existing, and if the method instantiated is static, it's not assured.

读书人网 >编程

热点推荐