title: Scanning integers into a 2D arraylist?
body: <p>Ive tried different variations but I have no idea how to get this to work. Im trying to get the user to input co-ordinates that loops based off a number the user chooses, but the scanner doesnt seem to work very well with the 2d array.</p>
  
  <p>Edit: Added the rest of the code to clarify what im trying to achieve, I need to be able to delete rows out of the array and have the rest move up and use mathematical operations on them.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Scanner;
  import javax.swing.JOptionPane;
  
  public class ConvexHull {
  
  public static void main(String[] args){
  
      int grid[][] = new int [10][10];
      int points = 0;
      boolean upperhull = false;
      boolean lowerhull = false;
  
      Scanner intScanner = new Scanner(System.in);
  
      System.out.println( "Enter number of coordinates to evaluate: " );
      points = intScanner.nextInt();
  
      ArrayList coords[][] = new ArrayList[points][2];
  
      for(int i=0; i&lt;points; i++){
          System.out.println( "Enter the x-coordinate for point " + ( i + 1 ) );
          coords.add([i][0], intScanner.next());
  
          System.out.println( "Enter the y-coordinate for point " + ( i + 1 ) );
          coords[i][1] = intScanner.nextInt();
      }
          for (int i=0; i &lt;= coords.length; i++)
           for (int x=0; x &lt; coords.length-1; x++)
                if (coords[x][0] &gt; coords[x+1][0])
                  {
                      int temp[] = coords[x];
                      coords[x] = coords[x+1];
                      coords[x+1] = temp;
                  }
  
      for(int j=0; j&lt;points; j++){    
      System.out.println("Co-ordinates are " + coords[j][0] + "," + coords [j][1]);   
      }
  
      for(int k=0; k&lt;points-2; k=k-1){
  
  
      int ax = coords[k][0];
      int ay = coords[k][1];
      k++;
      int bx = coords[k][0];
      int by = coords[k][1];  
      k++;
      int cx = coords[k][0];
      int cy = coords[k][1];
  
  
      int turn = (bx - ax)*(cy-ay)-(by-ay)*(cx-ax);
  
          if (k==2){
              if (turn &gt; 0){
                  lowerhull = true;
                  System.out.println("Computing the lower hull");
              }
              else if (turn &lt; 0){
                  upperhull = true;
                  System.out.println("Computing the upper hull");
              }
              else if (turn == 0){
                  System.out.println("Its a straight line");
              }
                  }
          else if(lowerhull = true &amp;&amp; turn &lt; 0){
              coords[k-1][0] = 0;
              coords[k-1][1] = 0; 
          }
          else if(upperhull = true &amp;&amp; turn &gt; 0){
              coords[k-1][0] = 0;
              coords[k-1][1] = 0; 
          }
  
      }
  
      for(int j=0; j&lt;points; j++){    
      if(coords[j][0] != 0 &amp;&amp; coords [j][1] !=0)
      System.out.println("The convex hull points are " + coords[j][0] + "," + coords [j][1]);
  }
  }
  </code></pre>
  
  <p>}</p>