Skip to main content
Post Closed as "Duplicate" by Sotirios Delimanolis java
edited tags
Link
overexchange
  • 17.3k
  • 38
  • 192
  • 408
Source Link
overexchange
  • 17.3k
  • 38
  • 192
  • 408

Syntax for 'new' in java

Constructors of non static member classes take an extra hidden parameter which is a reference to an instance of the immediately enclosing class. There is also a syntactic extension of 'new'.

In the below code,

class K{ static class Ka{ static class Kb{ class Kc{ class Kd{ } } } } } class Test{ K.Ka.Kb.Kc.Kd k = new K.Ka.Kb().new Kc().new Kd(); } 

Can you please help me understand the meaning of Kb() in K.Ka.Kb().new Kc().new Kd()? I understand that new Kc() is required as told in first paragraph.