我想显示不同的字符串数组元素,如下所示:
- 俱乐部 1
- 红心王牌
- 钻石 9
CardGame.java:
public class CardGame {
public static void main(String[] args){
String[] suit = { "Clubs", "Hearts", "Diamonds", "Spades" };
String[] deck = { "2", "3", "4", "5", "6", "7", "8", "9", "10",
"Jack", "Queen", "King", "Aces" };
int i = (int) ( Math.random() * deck.length );
int j = (int) ( Math.random() * suit.length );
for( int a = 0; a < 7; a++ ) {
System.out.println( "Deck " + deck[i] + " Suit " + suit[j] );
}
System.out.println();
}
}
我将如何做?指出我显示这些不同元素的正确逻辑。谢谢。