How to properly enter input to check for 4 consecutive numbers
<p>I am trying to input a 6 row x 7 column list of values to be check in the program for 4 consecutive numbers either diagonally, vertically or horizontally. When I input the matrix of values and hit enter it goes to the next line. I have to click enter 10+ times before I get my output message of False or True. Does anyone have any suggestions to fix this? Thank you.</p>

<pre><code>import java.util.Scanner;
  public class ConsecutiveFour {
    private final int MATCH_COUNT = 4;
public static void main(String[] args) {
  Scanner input = new Scanner(System.in);

System.out.print("Enter number of rows: ");
int rows = input.nextInt();
    input.nextLine();

System.out.print("Enter number of columns: ");
int columns = input.nextInt();
    input.nextLine();


int[][] matrix = new int[rows][columns];

System.out.println("Enter " + matrix.length + " rows and " + matrix[0].length + " columns: ");
  for (int row = 0; row &lt; matrix.length; row++) {
  for (int column = 0; column &lt; matrix[row].length; column++){
    matrix[row][column] = input.nextInt();
       input.nextLine();
       int value = matrix[row][column];

  }
 }

 System.out.print("The Four Consecutive Numbers are:" + isConsecutiveFour(matrix));
  }


 public static boolean isConsecutiveFour(int[][] values) {
   boolean cons = false;
  int columns = values.length;
  int rows = values[0].length;



//tests horizontally

for (int r=0; r &lt; rows; r++) {
  for (int c=0; c &lt; columns - 3; c++){
    if (values[c][r] == values[c+1][r] &amp;&amp;
        values[c][r] == values[c+2][r] &amp;&amp;
        values[c][r] == values[c+3][r]) {
      cons = true;
    }
  }
}

//tests vertically
for (int r=0; r &lt; rows - 3; r++) {
  for (int c=0; c &lt; columns; c++){
    if (values[c][r] == values[c][r+1] &amp;&amp;
        values[c][r] == values[c][r+2] &amp;&amp;
        values[c][r] == values[c][r+3]) {
      cons = true;
    }
  }
}

//tests diagonally (going down and to the right)
for (int r=3; r &lt; rows; r++) {
  for (int c=0; c &lt; columns - 3; c++) {
    if (values[c][r] == values[c+1][r-1] &amp;&amp;
        values[c][r] == values[c+2][r-2] &amp;&amp;
        values[c][r] == values[c+3][r-3]) {
      cons = true;
    }
  }
}

//tests diagonally (going down and to the left)
for (int r=0; r &lt; rows - 3; r++) {
  for (int c=0; c &lt; columns - 3; c++) {
    if (values[c][r] == values[c+1][r+1] &amp;&amp;
        values[c][r] == values[c+2][r+2] &amp;&amp;
        values[c][r] == values[c+3][r+3]) {
      cons = true;
    }
  }
}
return cons;
}

}
</code></pre>
