public List<Interval> merge(List<Interval> intervals) {

		if (intervals == null || intervals.size() == 0)
			return result;
		Collections.sort(intervals, new IntervalComparator());
		Interval pre, cur, newI;
		pre = intervals.get(0);
		newI = new Interval();
		newI.start = pre.start;
		newI.end = pre.end;
		for (int i = 1; i < intervals.size(); i++) {
			cur = intervals.get(i);
			if (cur.start > newI.end) {
				result.add(newI);
				newI = new Interval();
				newI.start = cur.start;
				newI.end = cur.end;
			} else {
				if (cur.end > newI.end)
					newI.end = cur.end;
			}
			pre = cur;
		}
		result.add(newI);

		return result;
	}