Posts

Showing posts with the label treeset

Set interface in java with example

Read this article to know what is Set interface and its implemented classes in java with examples programs.  Set interface  represents a group of elements arranged as like an array. Set interface will grown dynamically when the elements are stored into it. Set will not allow duplicate elements to store into it. Set interface implemented classes are, HashSet<T> TreeSet<T> LinkedHashSet<T>           <T> represents the generic type of the storing element in set. Set interface methods: boolean add(Object) : Ensures the Set holds the argument. The Object is added only if it isn't already in the Set. Returns false if the Object was not added to the Set. void clear() : Removes all elements from the Set. boolean contains(Object) : Returns true if the Set contains the argument. boolean isEmpty() : Returns true if the Set contains no elements. ...