Skip to content

Instantly share code, notes, and snippets.

@diaolizhi diaolizhi/inner.java
Created Oct 13, 2018

Embed
What would you like to do?
创建泛型类中内部类对象
//内部类依赖于外部类,所以要先创建外部类对象
//第一种方式:
Outter outter = new Outter();
Outter.Inner inner = outter.new Inner(); //必须通过Outter对象来创建
//第二种方式:
Outter.Inner inner1 = outter.getInnerInstance();
//如果外部类是泛型类,可以这么写
Outter<String>.Inner inner1 = outter.getInnerInstance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.