Switch statement cases | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Switch statement cases

I'm writing a method to convert indexes to string. so index 1 is = "two" because i'm doing a deck.java program. I can do if else statements and return the string like this else if (index ==1) return "two"; but I wanted to know if I could use a switch statement instead. can a switch statement have case 0? because the if else start with index ==0; return "ace"

30th Aug 2018, 10:55 PM
Lesley
0 Answers