Java Reference
In-Depth Information
So far we showed only how to reuse existing method implementations and create method
references. But you can do something similar with constructors of a class.
3.6.2. Constructor references
You can create a reference to an existing constructor using its name and the keyword new as
follows: ClassName::new. It works similarly to a reference to a static method. For example,
suppose there's a zero-argument constructor. This fits the signature () -> Apple of Supplier; you
can do the following,
which is equivalent to
If you have a constructor with signature Apple(Integer weight), it fits the signature of the
Function interface, so you can do this,
which is equivalent to
Search WWH ::




Custom Search