public static void main(String[] args) { try { String content = "Java How to Program Book Paul Deitel Harvey Deitel"; Annotations annotations = new Annotations(); annotations.add(new Annotation(0, content.length(), "content")); annotations.add(new Annotation(0, content.length(), "content1")); annotations.add(new Annotation(0, 19, "title")); annotations.add(new Annotation(0, 19, "title1")); annotations.add(new Annotation(17, 40, "overlap1")); annotations.add(new Annotation(38, 45, "overlap2")); annotations.add(new Annotation(37, 50, "author")); annotations.sort(); for (Annotation s : annotations) { System.out.println(s.start + " " + s.end + " " + s.annotation); } } catch (InvalidAnnotationException ex) { ex.printStackTrace(); } System.out.println("Inserted"); }