write any two limitations of switch statement in Java
Answers
Answered by
5
Logical operators cannot be used with switch statement. For instance
case k>=20:
is not allowed
Switch case variables can have only int and char data type. So float or no data type is allowed.
For instance in the switch syntax given below:
switch(ch)
{
case 1:
statement-1;
break;
case 2:
statement-2;
break;
}
In this ch can be integer or char and cannot be float or any other data type
case k>=20:
is not allowed
Switch case variables can have only int and char data type. So float or no data type is allowed.
For instance in the switch syntax given below:
switch(ch)
{
case 1:
statement-1;
break;
case 2:
statement-2;
break;
}
In this ch can be integer or char and cannot be float or any other data type
Answered by
2
Answer:
The two limitations of switch statement in Java
Attachments:
Similar questions