Page 1 of 1

About Question enthuware.ocpjp.v7.2.1230 :

Posted: Mon Jun 29, 2015 3:04 pm
by romsky
FYI : case labels must be compile time constants. Thus, you cannot use non-final variable names as labels. final variables can be used.

OK:
public int m3(String a, int b) {
final String c = "a";
switch (a) {
case c:
return 1;
}
return 0;
}

Error:
public int m3(String a, int b) {
final String c = a;
switch (a) {
case c:
return 1;
}
return 0;
}


The statement "Thus, you cannot use non-final variable names as labels. final variables can be used." must be removed .

Re: About Question enthuware.ocpjp.v7.2.1230 :

Posted: Mon Jun 29, 2015 3:23 pm
by admin
You are right. Fixed.
thank you for your feedback!