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:
ConcurrentSkipListMap ceilingKey() method in Java with Examples
Next article icon

ConcurrentSkipListMap ceilingKey() method in Java with Examples

Last Updated : 13 May, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The ceilingKey() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which returns the least key greater than or equal to the given key. If there is no such value then null is returned. The method throws NullPointerException when there is no key. Syntax:

public K ceilingKey(K key)

Parameter: The function accepts a single mandatory parameter key which specifies the key. Return Value: The function returns the least key greater than or equal to key, or null if there is no such key. Exceptions: The method throws two types of exceptions:

  • ClassCastException: if the specified key cannot be compared with the keys currently in the map and
  • NullPointerException: if the specified key is null.

Below programs illustrate the above  method: Program 1: 

Java
// Java program to demonstrate // ceilingkey method in java  import java.util.concurrent.ConcurrentSkipListMap;  class GFG {     public static void main(String[] args)     {          // Initializing the set         // using ConcurrentSkipListMap()         ConcurrentSkipListMap<Integer, Integer>             mpp = new ConcurrentSkipListMap<Integer,                                             Integer>();          // Adding elements to this set         mpp.put(1, 1);         mpp.put(5, 2);         mpp.put(2, 7);          // Printing the ConcurrentSkipListMap         // Always in ascending order          System.out.println("Map: "                            + mpp);          System.out.println("key greater than or equal 3: "                            + mpp.ceilingKey(3));          System.out.println("key greater than or equal 2: "                            + mpp.ceilingKey(2));     } } 
Output:
Map: {1=1, 2=7, 5=2} key greater than or equal 3: 5 key greater than or equal 2: 2

Program 2: 

Java
// Java program to demonstrate // ceilingkey method in java import java.util.concurrent.ConcurrentSkipListMap;  class GFG {     public static void main(String[] args)     {          // Initializing the set         // using ConcurrentSkipListMap()         ConcurrentSkipListMap<Integer, Integer>             mpp = new ConcurrentSkipListMap<Integer,                                             Integer>();          // Adding elements to this set         mpp.put(11, 1);         mpp.put(51, 42);         mpp.put(92, 7);          // Printing the ConcurrentSkipListMap         // Always in ascending order          System.out.println("Map: "                            + mpp);          System.out.println("key greater than or equal 11: "                            + mpp.ceilingKey(11));          System.out.println("key greater than or equal 51: "                            + mpp.ceilingKey(51));     } } 
Output:
Map: {11=1, 51=42, 92=7} key greater than or equal 11: 11 key greater than or equal 51: 51

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListMap.html#ceilingKey-K-


Next Article
ConcurrentSkipListMap ceilingKey() method in Java with Examples

T

Twinkl Bajaj
Improve
Article Tags :
  • Misc
  • Java
  • Java-Collections
  • Java - util package
  • Java-Functions
  • Java-ConcurrentSkipListMap
  • Java-concurrent-package
Practice Tags :
  • Java
  • Java-Collections
  • Misc

Similar Reads

    ConcurrentSkipListMap clear() method in Java with Examples
    The clear() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which removes all of the mappings from this map. This means that all the elements from the map are removed and an empty map is returned. Syntax: public void clear() Parameter: The function does not accep
    2 min read
    ConcurrentSkipListMap put() method in Java with Examples
    The put() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced. Syntax: public V put(K key, V value) Parameter: Th
    2 min read
    ConcurrentSkipListMap size() method in Java with Examples
    The size() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which that is it returns the number of keys mapped to this map. The size() method is not a constant time operation. In case the map contains more than Integer.MAX_VALUE elements, the maximum value of the
    2 min read
    ConcurrentSkipListMap remove() method in Java with Examples
    The remove() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which removes the mapping for the specified key from this map. The method returns null if there is no mapping for of that particular key. After this method is performed the size of the map is reduced. S
    2 min read
    ConcurrentSkipListMap equals() method in Java with Examples
    The equals() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which to check the equality of this Map object with the specified object. The method returns true if the given object is also a map of the previous one and the two maps have the same mappings. Syntax: p
    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