-7
Hello.
I am trying to create a program that prints all 52 cards in the deck, from 1 to 10 and with all suits (Clubs, Diamonds, Hearts, Spades) and also print the cards Jack, Queen and King.
I found the use of "for" more appropriate in this case, but I do not have much knowledge with repetition functions, I would like to know how to print a "String" using "for"?
I am using this logic but it is not practical, because I would have to create a "for" for each number, I need a logic that simplifies this.
for (int i = 1; i <= 10; ++i) {
System.out.println(i + " De Paus");
}
}
}
Okay, thank you ! I’ll give a study..
– César Augusto
@Césaraugusto succeeds and does not forget to accept the answer as correct, it is important for other people who may have similar doubts in the future
– evandrobm
I’ll do it. But one question, in this link he is creating the Array with "int", if I want to create an Array of suits I would not have to save as "String" ?
– César Augusto
Arrays can be of the type you want, it can be an int array, String, if you want an Array of Arrays, this is what they call an Array
– evandrobm
I understood, in the case of a String array this would be the correct way to declare ? String[] naipesCartas = {"Hearts,Diamonds,Spades,Clubs"};
– César Augusto
A String is bounded by quotation marks, so the correct is to use
String[] naipesCartas = {"Copas","Ouros","Espadas","Paus"}
, so you have 4 strings being passed to your array, in your example there was only one string, with the content being the name of the 4 suits.– evandrobm
When writing code use a ` before and after the code to make it more readable.
– evandrobm
Perfect ! I’m managing to create a logic based on the material you sent me, not so hard, thanks for the help !
– César Augusto
You’re welcome, the community is here for this, helping those who are starting, any questions feel at home here at Stack Overflow
– evandrobm