Java Syntax expression.new MyClass -


having function

public parametermethodparameterbuilder withparameter() {         methodparameter parameter = new methodparameter();    return withparameter(parameter).new parametermethodparameterbuilder(parameter); } 

what mean of experession below

withparameter(parameter).new parametermethodparameterbuilder(parameter) 

the syntax obj.new inner() creates , returns instance of inner class(*) inner linked instance obj of encapsulating class.

when inner class declared, need instance of encapsulating class instantiate inner class. syntax confronted purpose.

here simplest example this:

public class mainclass {     public class innerclass {     } } 

you instantiate innerclass way:

mainclass mc = new mainclass(); mc.new innerclass(); 

(*) inner class = non-static nested class


Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -