I have a Card class
public class Card {
private int value, suit;
public Card(int value, int suit) {
this.value = value;
this.suit = suit;
}
//gets, sets, toString
}
This is how I would normally fill the ArrayList of Card
for(int suit = 1; suit <= 4; ++suit)
for(int value = 1; value <= 13; ++value)
Cards.add(new Card(value, suit));
But I want to use a Lambda expression to initialize it
ArrayList<Card> Cards = IntStream.range(1, 4)
.map(value -> IntStream.range(1, 13)
.map(suit -> new Card(value, suit)));
Intellij is giving me an error under .map(suit -> new Card(suit, value))
It says "Incompatible return type Card in lambda expression"