About Question enthuware.ocpjp.v7.2.1230 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
romsky
Posts: 39
Joined: Thu Jan 29, 2015 4:49 pm
Contact:

About Question enthuware.ocpjp.v7.2.1230 :

Post 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 .

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

You are right. Fixed.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests