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);