23.11.2017 Views

java_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java<br />

TreeSet(SortedSet ss)<br />

4<br />

This constructor builds a TreeSet that contains the elements of the given<br />

SortedSet.<br />

Apart from the methods inherited from its parent classes, TreeSet defines the following<br />

methods:<br />

Sr. No.<br />

1<br />

2<br />

3<br />

4<br />

Methods with Description<br />

void add(Object o)<br />

Adds the specified element to this set if it is not already present.<br />

boolean addAll(Collection c)<br />

Adds all of the elements in the specified collection to this set.<br />

void clear()<br />

Removes all of the elements from this set.<br />

Object clone()<br />

Returns a shallow copy of this TreeSet instance.<br />

Comparator comparator()<br />

5<br />

6<br />

7<br />

Returns the comparator used to order this sorted set, or null if this tree set<br />

uses its elements natural ordering.<br />

boolean contains(Object o)<br />

Returns true if this set contains the specified element.<br />

Object first()<br />

Returns the first (lowest) element currently in this sorted set.<br />

SortedSet headSet(Object toElement)<br />

8<br />

9<br />

10<br />

Returns a view of the portion of this set whose elements are strictly less than<br />

toElement.<br />

boolean isEmpty()<br />

Returns true if this set contains no elements.<br />

Iterator iterator()<br />

Returns an iterator over the elements in this set.<br />

404

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!