title: How to break out of while loop while continuing to iterate in nested for loop
body: <p>so what I am trying to do is validate that my user is only entering the numbers 1-4 using commas with no duplicates. For example, 1,2,3,4 or 2,1,4,3. I have included a while loop in order to make sure the user inputs the correct information. I am getting confused when it comes to the for loop because I am not sure whether or not I need to have an additional for loop in order to access that the array within the array using i and j? I am really confused and I am seeking some kind of assistance. I currently only have experience in Python.</p>
  
  <p>I realize that when I break out of the while loop to input the values into the array, once I return to ask the user for the next row's values, my for loop's initialization and update has restarted.</p>
  
  <p>I have also attempted to change my if statement to: <code>if (row1Values4x4.charAt(k) &gt; '0' &amp;&amp; row1Values4x4.charAt(k) &lt; '5') {</code> 
  however, that does not make sense because I want to break out of the loop when my for loop comes across a value that is not in the range of 1-4. </p>
  
  <p>I am not getting any errors, it is not working the way I want it to. </p>
  
  <pre><code>import java.util.Scanner;
  </code></pre>
  
  <p>public class sudokuPractice {</p>
  
  <pre><code>/**
   * @param args
   */
  public static void main(String[] args) {
      // TODO Auto-generated method stub
      int[][] fourArray = { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} };
              int row = 1;
              int k = 0;
              while (row &lt; 5) 
              {
                  String row1Values4x4 = "-1";
                  boolean done = false;
                  while (!done)
                  {
                      Scanner firstRow4x4 = new Scanner(System.in);
                      System.out.println("Please enter four values using commas for row " + row); //this needs to loop
                      row1Values4x4 = firstRow4x4.next();
                      row1Values4x4 = row1Values4x4.replaceAll(" ",""); //this is in case user enters numbers with spaces
                      if (row1Values4x4.length() == 7) {
                          for (k = 0; k &lt; row1Values4x4.length();k++) {
                                  if (row1Values4x4.charAt(k) &lt; '0' &amp;&amp; row1Values4x4.charAt(k) &gt; '5') {
                                      done = true;
                                  } //else {
                                  //}
                              }
                      }
                  }
                  String strArray[] = row1Values4x4.split(",");
                  int arraySidesInteger[] = new int[strArray.length];
                  for (int i = 0;  i &lt; strArray.length;  i++) {
                      arraySidesInteger[i] = Integer.parseInt(strArray[i]);
                  }
                  fourArray[row-1] = arraySidesInteger;
                  for (int i = 0; i &lt; fourArray.length; i++) {
                      for (int j = 0; j &lt; fourArray.length; j++)
                          System.out.print(fourArray[i][j] + " ");
                      System.out.println();
                  }
                  row++;
                  k++;
                  }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>//I included the integer k because I was trying to retain the initialization and update of my for loop. </p>