我在查看String.toUpperCase()的源代码时,偶然发现了这个语法,这对我来说是非常陌生的。什么意思?
scan: {
for (firstLower = 0 ; firstLower < len; ) {
int c = (int)value[firstLower];
int srcCount;
if ((c >= Character.MIN_HIGH_SURROGATE)
&& (c <= Character.MAX_HIGH_SURROGATE)) {
c = codePointAt(firstLower);
srcCount = Character.charCount(c);
} else {
srcCount = 1;
}
int upperCaseChar = Character.toUpperCaseEx(c);
if ((upperCaseChar == Character.ERROR)
|| (c != upperCaseChar)) {
break scan;
}
firstLower += srcCount;
}
return this;
}我不太明白scan是干什么用的。是关键字吗?我甚至试过这个简单的程序,它运行。
public static void main(String[] args) {
scan:
{
System.out.println("Hello");
}
}发布于 2018-02-03 11:15:10
那是跳出的标签。
参考这里。很像汇编语言,很可能是衍生出来的.
https://stackoverflow.com/questions/48596708
复制相似问题