title: How do I break from the main/outer loop in a double/nested loop?
body: <p>If I have loop in a loop and once an <code>if</code> statement is satisfied I want to break main loop, how am I supposed to do that?</p>
  
  <p>This is my code:</p>
  
  <pre><code>for (int d = 0; d &lt; amountOfNeighbors; d++) {
      for (int c = 0; c &lt; myArray.size(); c++) {
          if (graph.isEdge(listOfNeighbors.get(d), c)) {
              if (keyFromValue(c).equals(goalWord)) { // Once this is true I want to break main loop.
                  System.out.println("We got to GOAL! It is "+ keyFromValue(c));
                  break; // This breaks the second loop, not the main one.
              }
          }
      }
  }
  </code></pre>