Tree Set: ========= Set Interface ==> Sorted Set Interface ==> Navigable interface ==> Tree Set Class -> Tree Set Class which implements from Navigable Interface which extends from Sorted Set Interface which extends from Set Interface -> TreeSet class same as "TreeMap". -> At the time of TreeSet object creation, the JVM can reserve the internal capacity as 16 for TreeSet and with load factor of '0.75'. Methods: ======= 1) first() 2) last() 3) subset(E from, E to) 4) splitrerator() 5) tailSet(E from) =========== ==> return a set, whose elements are greater or equal fromElement 6) headset(E from) ================== ==> return a set, whose elements are lesser or equal to fromElement. set = {9,7,6,1,3,5} Sorted Set ==> {1,3,5,6,7,9} tailSet(7) ==> {7,9} headset(7) ==> {1,3,5,6,7} Methods of Navigable Interface: =============================== 1) higher(element) ================== ==> returns the least which should be strictly greater than the given element. 2) lower(element) ================= ==> returns the highest which should be strictly lesser than the element element. 3) ceiling(element) =================== ==> returns the element which should be greater than or equal. 4) floor(element) ================= ==> return the element which should be lesser than or equal. 5) pollFirst() ============== ==> return and remove the first element from the set. 6) pollLast() ============= ==> return and remove the last element from the set. s = {1,11,7,3,5,13,10} higher(5) ==> {1,3,4} ==> 4 lower(5) ==> {5,7,10,11,13} ==> 5 ceiling(5) ==> 13 package pack.p1; import java.util.TreeSet; class Book implements Comparable{ private String isbn; private String title; private String author; private int publicationYear; public Book(String isbn, String title, String author, int publicationYear) { super(); this.isbn = isbn; this.title = title; this.author = author; this.publicationYear = publicationYear; } public String getIsbn() { return isbn; } public String getTitle() { return title; } public String getAuthor() { return author; } public int getPublicationYear() { return publicationYear; } @Override public int compareTo(Book o) { return this.title.compareTo(o.title); } @Override public String toString() { return "Book [isbn=" + isbn + "]"; } } class LibraryCatalog{ TreeSet catalog = new TreeSet<>(); public void addBook(Book book) { catalog.add(book); } public void removeBook(Book book) { catalog.remove(book); } public Book searchByTitle(String title) { for(Book b:catalog) { if(b.getTitle().equalsIgnoreCase(title)) { return b; } } return null; } public void display() { for(Book b:catalog) { System.out.println(b); } } } public class DigitalLibrarySystem { public static void main(String[] args) { LibraryCatalog library = new LibraryCatalog(); library.addBook(new Book("123-ABC","Java Programming","John",2019)); library.addBook(new Book("ABC-321","Python Programming","Karthik",2020)); library.addBook(new Book("321-PQR","java programming fundamentals","Josef",2021)); library.addBook(new Book("PQR-123","python programming fundamentals","Mitchel",2023)); library.addBook(new Book("XYZ-123","Advanced Java Programming","LNRAO",2024)); library.addBook(new Book("123-XYZ","Advanced Python","Ashok IT",2023)); library.display(); Book f = library.searchByTitle("Advanced Java Programming"); System.out.println(f); } }