Java 8(Lambdas and Streams) and Collections
• A TreeSet uses compareTo(Object o) method implementation from Comparable interface to check for both duplicate elements as well as for sorting.
• A HashSet uses hashCode() and equals(Object o) method to check for duplicates
• From Java 8 onwards,Streams provide an efficient way to iterate over collections and for large data sets,parallel streams can be used for processing collections.
• For using a custom entity with collections,it is best practice to:
1)Override hashCode() and equals(Object o) methods
2)Implement Comparable<T> interface,providing implementation for compareTo(Object o) method
• For further info,please refer to document resource
https://github.com/shivamaggarwal7/Java-Basics/tree/master/resources