Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
Java Collections synchronizedNavigableSet() Method with Examples
Next article icon

Java Collections synchronizedNavigableSet() Method with Examples

Last Updated : 03 Jan, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The synchronizedNavigableSet() method in Java collections is used to get the thread-safe navigable set with the given navigable set.

Syntax:

public static <T> NavigableSet<T> synchronizedNavigableSet(NavigableSet<T> set)  

Parameters:

  • set is the input navigable set.

Return: It will return the synchronized navigable set from the given input (navigable set).

Exception: It will not raise any exception.

Example:

Java
// Java program to add elements // to the Navigable set and convert // them into the synchronized  // navigable set with string data import java.util.*;  public class GFG {     // main method     public static void main(String[] args)     {         // create an navigable tree set         NavigableSet<String> data = new TreeSet<>();          // add elements into the set         data.add("sravan-it");         data.add("manoj-cse");         data.add("sai-cse");         data.add("vignesh-it");          // get the synchronized navigable          // set from the above set         Set<String> final1             = Collections.synchronizedNavigableSet(data);          // display         System.out.println(final1);     } } 

Output
[manoj-cse, sai-cse, sravan-it, vignesh-it]

Example 2:

Java
// Java program to add elements to the Navigable // set and convert into the synchronized  // navigable set with integer data import java.util.*;  public class GFG {     // main method     public static void main(String[] args)     {         // create an navigable tree set         NavigableSet<Integer> data = new TreeSet<>();          // add elements into the set         data.add(7058);         data.add(4511);         data.add(7859);         data.add(4532);          // get the synchronized navigable          // set from the above set         Set<Integer> final1             = Collections.synchronizedNavigableSet(data);          // display         System.out.println(final1);     } } 

Output
[4511, 4532, 7058, 7859]

Example 3: 

Java
// Java program to remove an item // from the synchronized navigable // set import java.util.*;  public class GFG {     // main method     public static void main(String[] args)     {         // create an navigable tree set         NavigableSet<Integer> data = new TreeSet<>();          // add elements into the set         data.add(7058);         data.add(4511);         data.add(7859);         data.add(4532);          // get the synchronized navigable          // set from the above set         Set<Integer> final1             = Collections.synchronizedNavigableSet(data);          // remove 4511 element         final1.remove(4511);         // display         System.out.println(final1);     } } 

Output
[4532, 7058, 7859]

Next Article
Java Collections synchronizedNavigableSet() Method with Examples

M

manojkumarreddymallidi
Improve
Article Tags :
  • Java
  • Java-Functions
  • Java-Collections-Class
Practice Tags :
  • Java

Similar Reads

    Java Collections synchronizedNavigableMap​() Method with Examples
    NavigableMap is used for convenient navigation methods like lowerKey, floorKey, ceilingKey, and higherKey, along with this popular navigation method. It will take key-value pair as input We can create a navigable map by using the following syntax: NavigableMap<key_datatype, value_datatype> dat
    2 min read
    Collections synchronizedSet() method in Java with Examples
    The synchronizedSet() method of java.util.Collections class is used to return a synchronized (thread-safe) set backed by the specified set. In order to guarantee serial access, it is critical that all access to the backing set is accomplished through the returned set. Syntax: public static <T>
    2 min read
    Collections synchronizedList() method in Java with Examples
    The synchronizedList() method of java.util.Collections class is used to return a synchronized (thread-safe) list backed by the specified list. In order to guarantee serial access, it is critical that all access to the backing list is accomplished through the returned list. Syntax: public static <
    2 min read
    Collections synchronizedSortedSet() method in Java with Examples
    The synchronizedSortedSet() method of java.util.Collections class is used to return a synchronized (thread-safe) sorted set backed by the specified sorted set. In order to guarantee serial access, it is critical that all access to the backing sorted set is accomplished through the returned sorted se
    2 min read
    Java Collections unmodifiableNavigableSet​() Method with Examples
    In this article we will discuss about unmodifiableNavigableSet() method. Introduction This method is available in NavigableSet. It is an data structure that can store elements in an order. For this we have to use tree set. we can create a treeset by using the following syntax: NavigableSet<dataty
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences