Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a LABEL block be used without loop?

Tags:

java

labels

Can a LABEL block be used without loop? Any examples?

like image 456
Alexa Culin Avatar asked Dec 21 '09 12:12

Alexa Culin


2 Answers

Here is an example of using labels and break statements without a loop:

        block1: {
            if (a < 0) {
                break block1;
            }
            if (b < 0) {
                break block1;
            }
            return a + b;
        }
like image 57
kgiannakakis Avatar answered Oct 10 '22 06:10

kgiannakakis


  public static void main(String[] args)
  {
    hello: break hello;
  }
like image 35
eljenso Avatar answered Oct 10 '22 06:10

eljenso