+ 7

Which type of variable cannot pass through switch case? Explain why?

Please help me to ans this question. Thank you:)

6th Mar 2019, 3:40 AM
Ajeet Kumar Sah
Ajeet Kumar Sah - avatar
7 ответов
+ 13
A switch statement accepts arguments of type # char # byte # short # int # String # enum # Character # Byte # Integer # Short The following are not allowed : # long # float # double # boolean Examples of datatypes which are not allowed : // ------------------------------ long x = 1; switch (x) {//compile time error at this line because long is not allowed. } // ------------------------------ float x = 2.0f; switch (x) {//compile time error at this line because float is not allowed. } // ------------------------------ double x = 5.0; switch (x) {//compile time error at this line because double is not allowed. // ------------------------------ boolean x = true; switch (x) {//compile time error at this line because boolean is not allowed. } // ------------------------------
6th Mar 2019, 8:33 AM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
0
6th Mar 2019, 8:35 AM
Ajeet Kumar Sah
Ajeet Kumar Sah - avatar
0
Спасибо!
14th Mar 2019, 1:32 PM
Илья Тихон
0
Илья Тихон I don't know your language so please use English language. Thank you:)
14th Mar 2019, 2:06 PM
Ajeet Kumar Sah
Ajeet Kumar Sah - avatar
0
There is a floating point variables can't pass through switch
16th Mar 2019, 2:50 AM
Deepak Dhingan
Deepak Dhingan - avatar
0
Floating point
16th Mar 2019, 3:43 PM
Ankit Kumar
Ankit Kumar - avatar
- 1
Except int and char no other variable can pass through switch case.
6th Mar 2019, 8:32 AM
Adhit Narayanan
Adhit Narayanan - avatar