CollectionsUtil { public static int getEditDistance2Lists(List<? extends Object> list1, List<? extends Object> list2) { int[][] d = new int[list1.size() + 1][list2.size() + 1]; for (int i = 0; i < list1.size() + 1; i++) { d[i][0] = i; } for (int i = 0; i < list2.size() + 1; i++) { d[0][i] = i; } for (int j = 1; j < list2.size() + 1; j++) { for (int i = 1; i < list1.size() + 1; i++) { if (list1.get(i - 1).equals(list2.get(j - 1))) { d[i][j] = d[i - 1][j - 1]; } else { d[i][j] = Math.min(d[i - 1][j] + 1, Math.min(d[i][j - 1] + 1, d[i - 1][j - 1] + 1)); } } } return d[list1.size()][list2.size()]; }  static LinkedHashMap<K, V> sortByValue(
      Map<K, V> map); static LinkedHashMap<K, V> sortByValueDescending(
      Map<K, V> map); static int getHammingDistance2Lists(List<? extends Object> list1,
      List<? extends Object> list2); static int getHammingDistance2DiffLists(List<? extends Object> list1,
      List<? extends Object> list2); static int getEditDistance2Lists(List<? extends Object> list1,
      List<? extends Object> list2); static double getJaroWinklerDistance2Lists(
      List<? extends Object> list1, List<? extends Object> list2,
      double scalingFactor);  }
@Test public void testGetEditDistance2Lists() { List<Integer> list1 = new ArrayList<Integer>(); list1.add(1); list1.add(2); list1.add(3); List<Integer> list2 = new ArrayList<Integer>(); list2.add(1); list2.add(2); list2.add(3); List<Integer> list3 = new ArrayList<Integer>(); list3.add(2); list3.add(2); list3.add(3); List<Integer> list4 = new ArrayList<Integer>(); list4.add(2); list4.add(1); list4.add(3); List<Integer> list5 = new ArrayList<Integer>(); list5.add(2); list5.add(1); list5.add(2); System.out.println(CollectionsUtil.getEditDistance2Lists(list1, list2)); System.out.println(CollectionsUtil.getEditDistance2Lists(list1, list3)); System.out.println(CollectionsUtil.getEditDistance2Lists(list1, list4)); System.out.println(CollectionsUtil.getEditDistance2Lists(list1, list5)); Assert.assertTrue(CollectionsUtil.getEditDistance2Lists(list1, list2) == 0); Assert.assertTrue(CollectionsUtil.getEditDistance2Lists(list1, list3) == 1); Assert.assertTrue(CollectionsUtil.getEditDistance2Lists(list1, list4) == 2); Assert.assertTrue(CollectionsUtil.getEditDistance2Lists(list1, list5) == 2); }