I got Compiler error : missing return statement
After i changege the code below :
class Test {
String f(int i) {
switch(i) {
case 0 : return "A";
case 1 : return "B";
case 2 : return "C";
default : assert false;
}
return "s";
}
public static void main(String arg[]) {
Test t=new Test();
for(int i=0;i<4;i++) {
System.out.println(t.f(i));
}
}
compiled fine then enabled assertions :
java -ea Test
got the output as
A
B
C
Exception in
thread "main" java.lang.AssertionError
at Test.f(Test.java:4586)
at Test.main(Test.java:4595)
But Why Assertion error here ??