-3

I find a strange statement while reading the openjdk resources. enter image description here

what does the "found:{}" means?

1 Answers1

0

found:{} is a label in Java mainly used for goto statement but since Java doesn't use goto it can be used for break and continue statement. Here is an example of using a label in Java.

    loop: 
    for (int i = 0; i < 10; i++) { 
        for(int j=0; j<10; j++)
        {
            if(j==5)
            {
                break loop;
            }
            System.out.println(j);
        }

    } 

When j reach 5 it will trigger break to outside loop label.

Pyrozen
  • 31
  • 1
  • 6
  • *"mainly used for goto statement"* Java doesn't have a `goto` statement. See: [Is there a goto statement in Java?](https://stackoverflow.com/q/2545103/5221149) – Andreas Mar 02 '19 at 06:43