import java.util.function.Function; public class TestClassTypeReference { public static void main(String[] args) { new TestClassTypeReference().test(); } // Test the use of method references of the form: "ClassType :: [TypeArguments] new" // See The Java Language Specification 15.13: Method Reference Expressions. void test() { char[] chars1 = {'A', 'B', 'C'}; Function test1 = String::new; // Notional String(char[]) constructor. String s1 = test1.apply(chars1); System.out.println("s1 = " + s1); // Prints "ABC" // Now repeat the previous test, but include some arbitrary [TypeArguments] in the method reference. char[] chars2 = {'1', '2', '3'}; // The following declaration compiles OK even though the four [TypeArguments] are meaningless. Function test2 = String::, Short, Byte[], Thread>new; // Compiles OK!? String s2 = test2.apply(chars2); System.out.println("s2 = " + s2); // Prints "123" } }