Listlist = Arrays.asList(new Point(1, 5), new Point(2, 3),new Point(2, 8), new Point(9, 13));int sum = list.get(0).y - list.get(0).x,currenty=list.get(0).y;Point pnext;for (int i = 1, len = list.size(); i < len; i++) {pnext = list.get(i);if (currenty >= pnext.y)continue;sum += currenty >= pnext.x ? pnext.y - currenty : pnext.y- pnext.x;currenty = pnext.y;}System.out.println(sum);