Problem statement:
what are the data types you cannot use as a parameter variable for switch statements in Java 8?
Following are the data types we cannot use as an input parameter variable for switch() statements.
what are the data types you cannot use as a parameter variable for switch statements in Java 8?
Following are the data types we cannot use as an input parameter variable for switch() statements.
- long
- float
- double
Error: Incompatible type found long, float and double.
public class SwitchStatement {
public static void main(String[] args) {
double d = 10.5d;
switch (d) {
case 10.5d:
System.out.println("double");
break;
default:
System.out.println("default");
break;
}
}
}
Error: Incompatible types. Found: 'double'
No comments:
Post a Comment