public class NewDeck {
public static void main(String[] args){
String[] suits = new String[] {"Clubs", "Diamonds", "Spades", "Hearts"};
String[] faces = new String[] {"Ace", "King", "Queen", "Jack"};
String[][] deck = new String[][] {{},{}};
int a = 0;
int b = 0;
for(String x: suits){
a ++;
for(String y: faces){
deck[a][b] = {{x, y}}; // THIS IS THE LINE I NEED HELP WITH
b++;
System.out.println(deck);
}
}
}
}
我期望打印的是:
{{"Clubs, "Ace"}{"Diamonds", "Ace"}{"Spades", "Ace"}{"Hearts", "Ace"}
{"Clubs, "King"}{"Diamonds", "King"}{"Spades", "King"}{"Hearts", "King"}
{"Clubs, "Queen"}{"Diamonds", "Queen"}{"Spades", "Queen"}{"Hearts", "Queen"}
{"Clubs, "Jack"}{"Diamonds", "Jack"}{"Spades", "Jack"}{"Hearts", "Jack"}
当我想打印时:
deck[4][0]
我希望它打印:
"Clubs"
我知道我非常接近它只有一条线我相信我做错了,所以我评论了导致问题的那条线。如果有人知道要放入什么而不是:
deck[a][b] = {{x, y}};
将不胜感激。感谢您提前提供任何答案