I'm not understanding something, obviously. I've got a primitive array of ints, and I need to convert that into an array of my own type. Here's what I've tried.
public class StupidInt {
@JsonProperty("ID")
private int id;
public StupidInt(int id) { this.id = id; }
public int getId() { return this.id; }
}
public static void main(String []args){
int[] ints = {1,2,4,67};
StupidInt[] myInts = IntStream.of(ints).map(StupidInt::new).collect(Collectors.toList());
}
As you might expect, myInts line has a problem and that problem is "cannot convert StupidInt to int". But I'm not sure what combination of map or foreach or whatever intermediate and terminal methods to use to convert that array of ints to an array of my object. What is the correct way to do this conversion?