difference between hashset and treeset in java code example Example: treeset in java - TreeSet sorts the order and don't accept null