Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

The comment of the previous folk is totally right. You are not adding the created cards to the list.

Try replacing your code

final List<Card> deck = Stream.of(CardType.values()). flatMap(type -> IntStream.rangeClosed(1, 4).mapToObj(num -> new Card(type, "CardName" + num))). collect(toList()); 

for standard list creation and adding. For instance (and updated for 4 cards):

List<Card> deck = new ArrayList<Card>(); for (int i = 0; i < 4; i++){ deck.add(card1); deck.add(card2); deck.add(card3); } 

If you want to minimise the number of lines of code, there are ways to initialise a new list with content. Try this post Initialization of an ArrayList in one lineInitialization of an ArrayList in one line.

Anyway, always try to code the simplest solution, even more when starting with a new language.

The comment of the previous folk is totally right. You are not adding the created cards to the list.

Try replacing your code

final List<Card> deck = Stream.of(CardType.values()). flatMap(type -> IntStream.rangeClosed(1, 4).mapToObj(num -> new Card(type, "CardName" + num))). collect(toList()); 

for standard list creation and adding. For instance (and updated for 4 cards):

List<Card> deck = new ArrayList<Card>(); for (int i = 0; i < 4; i++){ deck.add(card1); deck.add(card2); deck.add(card3); } 

If you want to minimise the number of lines of code, there are ways to initialise a new list with content. Try this post Initialization of an ArrayList in one line.

Anyway, always try to code the simplest solution, even more when starting with a new language.

The comment of the previous folk is totally right. You are not adding the created cards to the list.

Try replacing your code

final List<Card> deck = Stream.of(CardType.values()). flatMap(type -> IntStream.rangeClosed(1, 4).mapToObj(num -> new Card(type, "CardName" + num))). collect(toList()); 

for standard list creation and adding. For instance (and updated for 4 cards):

List<Card> deck = new ArrayList<Card>(); for (int i = 0; i < 4; i++){ deck.add(card1); deck.add(card2); deck.add(card3); } 

If you want to minimise the number of lines of code, there are ways to initialise a new list with content. Try this post Initialization of an ArrayList in one line.

Anyway, always try to code the simplest solution, even more when starting with a new language.

added 388 characters in body
Source Link

The comment of the previous folk is totally right. You are not adding the created cards to the list.

Try replacing your code

final List<Card> deck = Stream.of(CardType.values()). flatMap(type -> IntStream.rangeClosed(1, 4).mapToObj(num -> new Card(type, "CardName" + num))). collect(toList()); 

for standard list creation and adding. For instance (and updated for 4 cards):

List<Card> deck = new ArrayList<Card>(); for (int i = 0; i < 4; i++){ deck.add(card1);  deck.add(card2);  deck.add(card3); } 

If you want to minimise the number of lines of code, there are ways to initialise a new list with content. Try this post Initialization of an ArrayList in one line.

Anyway, always try to code the simplest solution, even more when starting with a new language.

The comment of the previous folk is totally right. You are not adding the created cards to the list.

Try replacing your code

final List<Card> deck = Stream.of(CardType.values()). flatMap(type -> IntStream.rangeClosed(1, 4).mapToObj(num -> new Card(type, "CardName" + num))). collect(toList()); 

for standard list creation and adding. For instance:

List<Card> deck = new ArrayList<Card>(); deck.add(card1); deck.add(card2); deck.add(card3); 

The comment of the previous folk is totally right. You are not adding the created cards to the list.

Try replacing your code

final List<Card> deck = Stream.of(CardType.values()). flatMap(type -> IntStream.rangeClosed(1, 4).mapToObj(num -> new Card(type, "CardName" + num))). collect(toList()); 

for standard list creation and adding. For instance (and updated for 4 cards):

List<Card> deck = new ArrayList<Card>(); for (int i = 0; i < 4; i++){ deck.add(card1);  deck.add(card2);  deck.add(card3); } 

If you want to minimise the number of lines of code, there are ways to initialise a new list with content. Try this post Initialization of an ArrayList in one line.

Anyway, always try to code the simplest solution, even more when starting with a new language.

Source Link

The comment of the previous folk is totally right. You are not adding the created cards to the list.

Try replacing your code

final List<Card> deck = Stream.of(CardType.values()). flatMap(type -> IntStream.rangeClosed(1, 4).mapToObj(num -> new Card(type, "CardName" + num))). collect(toList()); 

for standard list creation and adding. For instance:

List<Card> deck = new ArrayList<Card>(); deck.add(card1); deck.add(card2); deck.add(card3);