February 2014
Intermediate to advanced
160 pages
4h 59m
English
| | Supplier<Heavy> supplier = Heavy::new; |
Instead of invoking a constructor, we can ask the Java compiler to create the calls to the appropriate constructor from the concise constructor-reference syntax. These work much like method references, except they refer to a constructor and they result in object instantiation. The preceding sample code is equivalent to this:
| | Supplier<Heavy> supplier = () -> new Heavy(); |