Is it possible to use an int[] to create Foo[] where Foo takes that int into the constructor using a stream. Java 11

Basically I have an array of integers and I need to change that to an array of an object which takes an integer for the constructor. I was just wondering if this was possible using a stream in java 11.

Answer

int input[] = {1, 2, 3, 4, 5};
YourClass[] output = IntStream.of(input)
        .mapToObj(YourClass::new)
        .toArray(YourClass[]::new);