title: User Input java 2d Array
body: <p>I need to create code that takes user input to create the size of the 2d array (rows and columns must be less than 6), then fill it up with values that the user gives (between -10 and 10). My loop for taking the values isn't working at all and I'm not sure why. Here's the code</p>
  
  <pre><code>    import java.util.Scanner;
  
    public class Matrix {
  
        public static void main(String[] args) {
            // TODO Auto-generated method stub
  
      // Implement scanner
      Scanner input = new Scanner(System.in);
  
      // create loop for accepting matrix input
      // first accept row size
      System.out.println("Please enter the number of rows in your matrix.      Must be 5 or less.");
      int row = input.nextInt();
      while (row &gt; 5 || row &lt; 1) {
          System.out.println("Sorry. Your number is not the correct size. "
                  + "Please enter the number of rows in your matrix. Must be between 5 and 1.");
          row = input.nextInt();
      }
      // next accept column size
      System.out.println("Please enter the number of columns in your matrix. Must be 5 or less.");
      int column = input.nextInt();
      while (column &gt; 5 || column &lt; 1) {
          System.out.println("Sorry. Your number is not the correct size. "
                  + "Please enter the number of columns in your matrix. Must be between 5 and 1.");
          column = input.nextInt();
      }
      // declare array with row and columns the user gave
      int[][] userArray = new int[row][column];
  
      // create loop for accepting values within the matrix
      // first loop for row values
      for (int i = 0; i &lt; userArray.length; i++) {
          System.out.println("Please enter numbers between -10 and 10 for your matrix rows");
          int rowValues = input.nextInt();
          while (rowValues &gt; 10 || column &lt; -10) {
              System.out.println(
                      "Sorry. Your number is not the correct size. " + "Please enter a number between 10 and -10.");
              rowValues = input.nextInt();
          }
  
          // second embedded loop for column values
          for (int j = 0; j &lt; userArray[i].length; j++) {
              System.out.println("Please enter numbers between -10 and 10 for your matrix columns");
              int columnValues = input.nextInt();
              while (columnValues &gt; 10 || column &lt; -10) {
                  System.out.println("Sorry. Your number is not the correct size. "
                          + "Please enter a number between 10 and -10.");
                  columnValues = input.nextInt();
              }
          }
      }
  
      printMatrix(userArray);
  }
  </code></pre>