Ad
  • Custom User Avatar

    TreeSet preserves the elements in distinct sorted order, and the last return just strips unwanted characters from .toString() method (by default it will return something like "[a, b, c, d, e]"). Because the toString() output may change I think this is not best method. Using StringBuilder is much better.