- 1

What is switch I am not understand it മലയാളികളുണ്ടെങ്കിൽ മലയാളത്തിലൊന്ന് പറഞ്ഞ് തരണേ

what is switch in java and what is it's use

29th Oct 2017, 5:44 AM
ajmal yousuf
ajmal yousuf - avatar
3 Answers
+ 4
switch(condition){ case(possible match){execute code} case(possible match){execute code} default{code run if no match} }
29th Oct 2017, 5:55 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
A switch statement is a replacement for writing multiple if-else statements. So if you want to run different code blocks depending on the day of the week you would use a switch. switch (day){ case 1{ println ("Today is Sunday") } case 2{ println ("Today is Monday") } case 3{ println ("Today is Tuesday") } case 4{ println ("Today is Wednesday") } case 5{ println ("Today is Thursday") } case 6{ println ("Today is Friday") } case 7{ println ("Today is Saturday") } } So if the variable day=5 the program would print Thursday to the screen.
29th Oct 2017, 6:59 AM
Adam
Adam - avatar
0
Thanks
30th Oct 2017, 3:36 PM
ajmal yousuf
ajmal yousuf - avatar