Break statement inside two while loops

It will break only the most immediate while loop. Using a label you can break out of both loops: take a look at this example taken from here


public class Test {
  public static void main(String[] args) {
    outerloop:
    for (int i=0; i < 5; i++) {
      for (int j=0; j < 5; j++) {
        if (i * j > 6) {
          System.out.println("Breaking");
          break outerloop;
        }
        System.out.println(i + " " + j);
      }
    }
    System.out.println("Done");
  }
}

In your example break statement will take you out of while(b) loop

while(a) {

   while(b) {

      if(b == 10) {
         break;
      }
   }  
   // break will take you here.
}