I'm new to java, but my understanding is that the keyword new
comes before a constructor. However, in this example from Oracle's Java Tutorial, this is not the case.
public static int numSuits = 4;
public static int numRanks = 13;
public static int numCards = numSuits * numRanks;
private Card[][] cards;
public Deck() {
cards = new Card[numSuits][numRanks];
for (int suit = Card.DIAMONDS; suit <= Card.SPADES; suit++) {
for (int rank = Card.ACE; rank <= Card.KING; rank++) {
cards[suit-1][rank-1] = new Card(rank, suit);
}
}
}
Card is class, and I do not understand what this line means:
cards = new Card[numSuits][numRanks];
Can someone please explain what this line of code means.