8000 Create README.md · ruturajjadhav07/Java@c3efd0c · GitHub
[go: up one dir, main page]

Skip to content

Commit c3efd0c

Browse files
Create README.md
1 parent 0bda613 commit c3efd0c

File tree

1 file changed

+23
-0
lines changed
  • Java Core/Java Collection Framework/Set /TreeSet

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Treeset
2+
*TreeSet is a class in Java that implements the Set interface. It is used to store a sorted collection of unique elements, meaning it does not allow duplicate values.*
3+
*TreeSet internally uses a Red-Black tree data structure to maintain the elements in sorted order.*
4+
5+
## There are many methods related to TreeSet Here are most common that are used
6+
7+
### 1. add(E element):
8+
* This method adds the specified element to the TreeSet if it is not already present. If the element is already present, the set remains unchanged.
9+
10+
### 2. contains(Object o):
11+
* This method returns true if the TreeSet contains the specified element; otherwise, it returns false.
12+
13+
### 3. remove(Object o):
14+
* This method removes the specified element from the TreeSet if it is present. Returns true if the element was present and successfully removed; otherwise, returns false.
15+
16+
### 4. size():
17+
* This method returns the number of elements in the TreeSet.
18+
19+
### 5. isEmpty():
20+
* This method returns true if the TreeSet contains no elements; otherwise, returns false.
21+
22+
### 6. clear():
23+
* This method removes all elements from the TreeSet.

0 commit comments

Comments
 (0)
0