Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1193 :

Posted: Sun Jan 24, 2016 8:07 am
by RalucaD
The explanation says:
It is not possible to break out of an if statement. But if the if statement is placed within a switch statement or a loop construct, the usage of break in option 3 would be valid.
But what about break with label?

Code: Select all

public class Q33{
	public static void main(String[] args){
		label: if(true){
			System.out.println("break label");
			break label;
		}
	}
}

Re: About Question enthuware.ocajp.i.v8.2.1193 :

Posted: Sun Jan 24, 2016 9:47 pm
by admin
break with a label is possible. This has now been added to the explanation.
thank you for your feedback!