Syntax for 'new' in java
This question already has an answer here:
It's calling the constructor of Kb . It's easier to show this in three statements:
K.Ka.Kb x1 = new K.Ka.Kb();
K.Ka.Kb.Kc x2 = x1.new Kc(); // Pass x1 as the hidden constructor arg
K.Ka.Kb.Kd.Kd k = x2.new Kd(); // Pass x2 as the hidden constructor arg
The parentheses you point out actually do not apply to Kb but K.Ka.Kb .
new K.Ka.Kb()
is creating a new instance of the K.Ka.Kb nested class.
Kb() is the default constructor for class Kb . It is what relates to the first new of the line:
Kb (class K.Ka.Kb actually ; depending on the context you may omit K.Ka. ) new Kc() for creating a new instance of Kc new Kd() for creating a new instance of Kd 上一篇: 使用静态内部类
下一篇: java中'new'的语法
