I recently came across the above code in one of the article. Though I understand that ::new is used to pass the instance of the class. I would love to really read and understand about ::new. Can someone has any article links about it?
Depending on the functional interface used for DefaulableFactory.create, DefaultableImpl::new can mean one of several things:
- If create takes a Supplier or Callable, it means () -> new DefaultableImpl().
- If create takes a Function (IntFunction, LongFunction, DoubleFunction), it means t -> new DefaultableImpl(t).
- If create takes a BiFunction, it means (t, u) -> new DefaultableImpl(t, u).
There are more out-of-the-box functional interfaces, and there can be even more, but you should get the picture.