I want to display various elements of a string array, for example:
- Clubs 1
- Hearts ace
- Diamonds 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(); } }
How can I do it? Guide me to correct the display logic of these different elements. Thanks.
source share