Try this:
new Card(new Suit(i), new String[]{j + ""}, j)
You were passing as second parameter j + ""
, which is a String
. To pass a String[]
, which is the expected type, just pack that string into a single-element array: new String[]{j + ""}
.
On a more fundamental level: why is the card rank defined as a String[]
in the first place? it should be a String
, a single card only has one rank! better fix the Card
class and change it to have a private String cardRank
as attribute:
public class Card {
private Suit suit = null;
private String cardRank;
private int cardValue = 0;
public Card(Suit suit, String cardRank, int cardValue) {
this.cardRank = cardRank;
this.suit = suit;
this.cardValue = cardValue;
}
}
Now the original initialization code will work as intended:
new Card(new Suit(i), j + "", j)