I have two lists as follow
List<String> color = new ArrayList<>();
color.add("red");
color.add("white");
color.add("pink");
List<Specification> specList = new ArrayList<>();
Specification soundSystem = new Specification("MusicSysten", "harman Kardon");
Specification price = new Specification("Price", "50000");
specList.add(soundSystem);
specList.add(price);
I want to create a new instance of specification object for each color item and add that to the specList. I tried something like this, But it's not working.
List<Specification> output = color.stream().map(c -> specList.add(new Specification("color", c))).collect(Collectors.toList());
the output I want here is something like
List<List<Specification>> output = [[(new Specification("MusicSysten", "harman Kardon"), new Specification("Price", "50000"), new Specification("Color", "red"))], [(new Specification("MusicSysten", "harman Kardon"), new Specification("Price", "50000"), new Specification("Color", "white"))], [(new Specification("MusicSysten", "harman Kardon"), new Specification("Price", "50000"), new Specification("Color", "pink"))] ]
Any suggestion?