how can I convert this to a List of the same object type?
TreeSet<FieldBean> Fields = new TreeSet<FieldBean>();
Thanks
TreeSet cannot contain duplicate elements. The elements in a TreeSet are sorted as per their natural ordering, or based on a custom Comparator that is supplied at the time of creation of the TreeSet. TreeSet cannot contain null value.
TreeSet does not allow to insert heterogeneous objects because it must compare objects to determine sort order. TreeSet is not synchronized. If multiple threads access a hash set concurrently, and at least one of the threads modifies the set, it must be synchronized externally. Use Collections.
TreeSet is one of the most important implementations of the SortedSet interface in Java that uses a Tree for storage. The ordering of the elements is maintained by a set using their natural ordering whether or not an explicit comparator is provided.
One of the constructors of ArrayList
takes a collection as an argument and fills the list with the items contained in that collection:
List<FieldBean> list = new ArrayList<FieldBean> (fields);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With