package class2_3_NestedLoops_start; import java.util.List; public class Driver { public static void main(String[] args) { List points = new ArrayList(); points.add(new Point(1,5)); points.add(new Point(3,4)); points.add(new Point(4, 3)); points.add(new Point(5, 1)); int minI = -1; int minJ = -1; double minDistance = Double.MAX_VALUE; for(int i = 0; i < points.size(); i++) { for(int j = 0; j < points.size(); j++) { if(i != j) { double currentDistance = points.get(i).distance(points.get(j)); if (currentDistance < minDistance) { minI = i; minJ = j; minDistance = currentDistance; } } } } if(minI < 0) { System.out.println("There are no points!"); } else { System.out.println("The closest points are: "+points.get(minI)+" and "+points.get(minJ)); System.out.println("They are " + minDistance + " cm apart"); } } }