- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ConcurrentSkipListSet in Java
The ConcurrentSkipListSet has elements that are sorted by default. Also, its implementation is based on the ConcurrentSkipListMap. The ConcurrentSkipListSet class also implements the Collection interface as well as the AbstractSet class. It is a part of the Java Collection Framework.
A program that demonstrates this is given as follows −
Example
import java.util.concurrent.ConcurrentSkipListSet; public class Demo { public static void main(String[] args) { ConcurrentSkipListSet<Integer> csls = new ConcurrentSkipListSet<Integer>(); csls.add(7); csls.add(4); csls.add(1); csls.add(9); csls.add(3); System.out.println("The elements in ConcurrentSkipListSet are: " + csls); } }
The output of the above program is as follows −
Output
The elements in ConcurrentSkipListSet are: [1, 3, 4, 7, 9]
Now let us understand the above program.
The ConcurrentSkipListSet is created and then elements are added to it. Then the elements are displayed and these are sorted by default. A code snippet that demonstrates this is given as follows −
ConcurrentSkipListSet<Integer> csls = new ConcurrentSkipListSet<Integer>(); csls.add(7); csls.add(4); csls.add(1); csls.add(9); csls.add(3); System.out.println("The elements in ConcurrentSkipListSet are: " + csls);
Advertisements
To Continue Learning Please Login
Login with Google