Created
October 13, 2018 11:23
-
-
Save diaolizhi/8708eefaffc336d0563350dbcd1c6317 to your computer and use it in GitHub Desktop.
创建泛型类中内部类对象
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//内部类依赖于外部类,所以要先创建外部类对象 | |
//第一种方式: | |
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