The best thing you can do is something like this (see below). Therefore, in some cases (no pun intended :)), it is better to use the if statement.
switch(card){ case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: suit="Hearts"; break; }
However, another approach that you might consider is to use a map.
Map<Integer, String> map = new HashMap<Integer, String>(); for (int i = 1; i <= 14; ++i) { map.put(i, "Hearts"); } for (int i = 15; i <= 26; ++i) { map.put(i, "Clubs"); }
Then you can search for a card suit with a card.
String suit1 = map.get(12);
source share