I have a list of enum like this :
public enum Fruit {
Apple,
Mango,
Banana,
kiwi
}
and I have class like this
public class FruitShop {
private String name;
public FruitShop(String name) {
this.name = name
}
I want to create a list of object of FruitShop class passing each enum as an arument
List<FruitShop> shoplists = new new ArrayList<>()
shoplists.add(Fruit.Apple.name())
shoplists.add(Fruit.Mango.name())
shoplists.add(Fruit.Banana.name())
shoplists.add(Fruit.kiwi.name())
How can I achieve this using java8 stream?
shoplists.add(Fruit.Apple.name())work with your existing code?