I was browsing through some of the base Java objects when I found a section of code surrounded by a scan: {}
block. The following code is from the toLowerCase() method inside the String class.
scan: {
for (firstUpper = 0 ; firstUpper < len; ) {
char c = value[firstUpper];
if ((c >= Character.MIN_HIGH_SURROGATE)
&& (c <= Character.MAX_HIGH_SURROGATE)) {
int supplChar = codePointAt(firstUpper);
if (supplChar != Character.toLowerCase(supplChar)) {
break scan;
}
firstUpper += Character.charCount(supplChar);
} else {
if (c != Character.toLowerCase(c)) {
break scan;
}
firstUpper++;
}
}
return this;
}
Could someone please explain what the scan:{}
block is used for and where this syntax comes from? I've yet to see a colon after a word like this in Java unless used in a ternary operator.
Thanks!
Edit: Updated title to correctly match answered question.