Is default case in a switch need to be placed at the end only? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Is default case in a switch need to be placed at the end only?

In switch case exercise, it is given that default case must be at end of the switch only. But what I red previously is default case may be at any place in switch. please anybody clarify this doubt.

14th Mar 2017, 2:29 PM
Shankaranarayana Barre
Shankaranarayana Barre - avatar
1 Answer
+ 14
You may place your default case anywhere, but it is a well-constructed norm to place it at the end of the list.
14th Mar 2017, 2:32 PM
Hatsy Rei
Hatsy Rei - avatar