+ 7
Which type of variable cannot pass through switch case? Explain why?
Please help me to ans this question. Thank you:)
7 odpowiedzi
+ 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.
}
// ------------------------------
0
thanks a lot Prokopios Poulimenos
0
Спасибо!
0
Илья Тихон I don't know your language so please use English language.
Thank you:)
0
There is a floating point variables can't pass through switch
0
Floating point
- 1
Except int and char no other variable can pass through switch case.