Exercise – Using the method reference to create a new object
Use the method reference to express creating a new object. Let's assume that we have class A{}. Replace the following Supplier function declaration with another one that uses the method reference:
Supplier<A> supplier = () -> new A();
Answer
The answer is:
Supplier<A> supplier = A::new;