I´m getting error non-static variable deck cannot be referenced from a static context from this piece of code. I would like to understand what wrong is going there. I´m new to java.
public class CardDeck extends java.lang.Object
{
private int size;
private Stack<Card> deck;
public CardDeck(int size)
{
this.deck = new Stack<Card>();
this.size = size;
}
public static CardDeck createStandardDeck()
{
for (int i = 1; i <= 13; i++) { deck.push(new Card(Card.Color.CLUBS,i)); }
for (int i = 1; i <= 13; i++) { deck.push(new Card(Card.Color.DIAMONDS,i)); }
for (int i = 1; i <= 13; i++) { deck.push(new Card(Card.Color.HEARTS,i)); }
for (int i = 1; i <= 13; i++) { deck.push(new Card(Card.Color.SPADES,i)); }
return deck;
}