title: Printing an array in a while loop
body: <p>I am trying to print my array using a method call once while the user inputs y or Y. I do not know how to get the array to only print once. </p>
  
  <p>I've researched and tried tweaking my own code but I am lost. </p>
  
  <pre><code>public class Lab10p1 {
  public static final int ROW = 5;
  public static final int COL = 6;
  public static final int MIN = 0;
  public static final int MAX = 100;
  
  /**
  * @param args the command line arguments
  */
  public static void main(String[] args) 
  {
      Scanner scan=new Scanner(System.in);
      System.out.println("Do you want to start Y/N?");
      char c =scan.next().charAt(0);
  
      while(c=='y'||c=='Y')
      {
          int[][] a = new int[ROW][COL]; 
          randArray(a, ROW, COL, MIN, MAX);
      }
  }
  
  public static void randArray(int[][] matrix, int row, int col, int low, int up)
  {     
      Random rand = new Random();   
      for (int r = 0; r &lt; row; r++)
      {          
          for (int c = 0; c &lt; col; c++)   
          {         
              int are=matrix[r][c] = rand.nextInt(up - low + 1) + low; 
              System.out.print(" "+are); 
          }       
          System.out.println();
      }
  }
  </code></pre>
  
  <p>the expected output is </p>
  
  <p>Do you want to continue(Y/N): y<br>
  The array elements are:<br>
  12 31 12 21 45 23<br>
  32 12 67 54 35 67<br>
  34 54 33 34 53 34<br>
  23 34 43 23 45 78<br>
  23 54 89 76 54 34  </p>
  
  <p>The actual results are an infinite loop of printing 6x5 arrays</p>