日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java ceilingentry_java.util.TreeMap.ceilingKey()

發布時間:2024/10/8 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java ceilingentry_java.util.TreeMap.ceilingKey() 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

描述

所述ceilingKey(K key)方法用來返回的最小鍵大于或等于給定鍵,則返回null如果不存在這樣的密鑰。

聲明

以下是java.util.TreeMap.ceilingKey()方法的聲明。

public K ceilingKey(K key)

參數

key - 這是匹配的關鍵。

返回值

方法調用返回大于或等于key的最小鍵,如果沒有這樣的鍵則返回null。

異常

ClassCastException - 如果無法將指定的鍵與當前映射中的鍵進行比較,則拋出異常。

NullPointerException - 如果指定的鍵為null并且此映射使用自然排序,或者其比較器不允許空鍵,則拋出異常。

實例

以下示例顯示了java.util.TreeMap.ceilingKey()方法的用法。

package com.tutorialspoint;

import java.util.*;

public class TreeMapDemo {

public static void main(String[] args) {

// creating tree map

NavigableMap treemap = new TreeMap();

// populating tree map

treemap.put(2, "two");

treemap.put(1, "one");

treemap.put(3, "three");

treemap.put(6, "six");

treemap.put(5, "five");

System.out.println("Ceiling key entry for 4: "+ treemap.ceilingKey(4));

System.out.println("Ceiling key entry for 5: "+ treemap.ceilingKey(5));

System.out.println("Ceiling key entry for 7: "+ treemap.ceilingKey(7));

}

}

讓我們編譯并運行上面的程序,這將產生以下結果。

Ceiling key entry for 4: 5

Ceiling key entry for 5: 5

Ceiling key entry for 7: null

總結

以上是生活随笔為你收集整理的java ceilingentry_java.util.TreeMap.ceilingKey()的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。