I am supposed to read an input of 4 coordinates Example: 0 1 1 1 (where 0 and 1 are the X and Y coordinates of the 1st point and 1 and 1 are the coordinates of the second point) How am I supposed to store these integers in an arraylist of type Point. Following is my approach :
  public class Project1 {
     private int m;
     private int n;
     private WeightedQuickUnionUF qu;
     private int[][] grid;
     private ArrayList<Point> connections;
    /**
    * initializes UnionFind structure, grid and connection list
    * @param m
    * @param n
    */
    public Project1(int m, int n){
    m=m;
    n=n;
    for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
     grid = new int[i][j];
    }
   }
 connections = new ArrayList<Point>();
 int size = m*n;
 qu = new WeightedQuickUnionUF(size);
   }
  public void read_input() 
  {
    Scanner sc = new Scanner(System.in);
    System.out.print("Enter number of pairs of connections:  ");
    int no_of_connections = sc.nextInt();
    for(int i=0; i < (no_of_connections * 4); i++){
    Point coordinates = (Point)sc.nextInt();
    connections.add(coordinates);
  }
   sc.close();
 } 
 
     
     
    