1

I was looking at the source code for String.toUpperCase() and I came across this syntax which is quite unfamiliar to me. What does it mean?

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;
    }

I couldn't quite understand what scan is for. Is it a keyword? I even tried this simple program and it ran.

public static void main(String[] args) {
    scan:
    {
        System.out.println("Hello");
    }
}
Kihats
  • 3,326
  • 5
  • 31
  • 46

1 Answers1

2

That's a Jump-out label.

Some reference here. Very similar to Assembly language by the way, probably derived...

Black.Jack
  • 1,878
  • 2
  • 22
  • 39