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
Post a Comment