Lambda: An array constructor reference builds an array of a given size

Type[]::new is a special constructor reference that takes an int length and produces a new array of that size, commonly used to supply an array factory without allocating one up front.

Code
IntFunction<String[]> newArray = String[]::new;
String[] arr = newArray.apply(3);
arr[0] = "a";
arr[1] = "b";
arr[2] = "c";
System.out.println("Length: " + arr.length);
System.out.println("Contents: " + Arrays.toString(arr));
Output
Length: 3
Contents: [a, b, c]
Advertisement
More in JAVA

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-09-27

© Java Coding Hub · About · Contact · Privacy · Terms