// Pair class public class Pair { private int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } public int getX( ) { return this.x; } public int getY( ) { return this.y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } @Override public String toString( ) { return String.format("(%d, %d)", this.x, this.y); } @Override public boolean equals(Object other) { return this.x == ((Pair) other).x && this.x == ((Pair) other).y; } } //------------------------------------------------------ // Main class import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Pair p = new Pair(2, 3); Pair q = new Pair(5, 6); System.out.println(p + " " + q); File f = new File("input.txt"); Scanner s = null; ArrayList col = new ArrayList< >( ); try { s = new Scanner(f); } catch (FileNotFoundException e) { System.out.println("File not found."); System.exit(1); } while(s.hasNextLine( )) { String line = s.nextLine( ); String[ ] fields = line.split(","); int x = Integer.parseInt(fields[0]); int y = Integer.parseInt(fields[1]); Pair r = new Pair(x, y); col.add(r); } System.out.println(col); } }