Convert HashSet to TreeSet in Java

In this post, we will see how to convert HashSet to TreeSet in Java. The resultant TreeSet should contain all elements of the HashSet, sorted by their natural ordering.