public class Solution { public static void main(String[] args) { double[][] set1 = {{1, 1}, {2, 2}, {3, 3}, {4, 4}}; double[][] set2 = {{0, 1}, {1, 2}, {4, 5}, {5, 6}}; double[][] set3 = {{0, 1}, {1, 2}, {4, 5}, {4.5, 4}}; System.out.println(isOnOneLine(set1)); System.out.println(isOnOneLine(set2)); System.out.println(isOnOneLine(set3)); } public static boolean isOnOneLine(double[][] array) { double sub = array[0][1] - array[0][0]; for(int i = 0; i < array.length; i++) { if(array[i][1] - array[i][0] != sub) return false; } return true; } }