Constructor Reference in Java
@FunctionalInterface interface MyInterface { Message send(String message); } class Message { public Message(String message) { System.out.println(message); } } class Test { public static void main(String[] args) { MyInterface myInterface = Message::new; myInterface.send(“Hello!”); } } Output: Hello! class Message { public Message(String message) { System.out.println(message); } public Message(String message1, String message2) { System.out.println(message1 + message2); }…
Read More Constructor Reference in Java