java treemap_Java TreeMap lastEntry()方法與示例

java treemap

TreeMap類的lastEntry()方法 (TreeMap Class lastEntry() method)

  • lastEntry() method is available in java.util package.

    lastEntry()方法在java.util包中可用。

  • lastEntry() method is used to return the entry (key-value pairs) that exists with the largest key element value in this TreeMap.

    lastEntry()方法用于返回此TreeMap中具有最大鍵值的條目(鍵值對)。

  • lastEntry() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    lastEntry()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • lastEntry() method does not throw an exception at the time of returning last entry.

    返回最后一個條目時, lastEntry()方法不會引發異常。

Syntax:

句法:

    public Map.Entry lastEntry();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of the method is Map.Entry, it returns those key-value pairs with the greatest key element value otherwise it returns null.

方法的返回類型為Map.Entry ,它返回鍵值最大的那些鍵值對,否則返回null。

Example:

例:

// Java program to demonstrate the example 
// of Map.Entry lastEntry() method of TreeMap 
import java.util.*;
public class LastEntryOfTreeMap {
public static void main(String[] args) {
// Instantiates TreeMap
TreeMap < Integer, String > tm = new TreeMap < Integer, String > ();
// By using put() method is
// to put the key-value pairs in
// treemap tm
tm.put(1, "C");
tm.put(4, "C++");
tm.put(3, "Java");
tm.put(2, "Php");
// Display TreeMap tm
System.out.println("tm: " + tm);
// By using lastEntry() method is
// used to return the key-value pairs
// linked with the largest key element 
// value i.e. 4
// Display Returned Key-Value Element
System.out.println("tm.lastEntry(): " + tm.lastEntry());
}
}

Output

輸出量

tm: {1=C, 2=Php, 3=Java, 4=C++}
tm.lastEntry(): 4=C++

翻譯自: https://www.includehelp.com/java/treemap-lastentry-method-with-example.aspx

java treemap

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541350.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541350.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541350.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

LeetCode OJ 之 Valid Anagram

題目&#xff1a; Given two strings s and t, write a function to determine if t is an anagram of s. For example,s "anagram", t "nagaram", return true.s "rat", t "car", return false. Note: You may assume the string…

oracle光標位置無效,解決在Form表單中光標移動不了問題

apply p8727236_10123 for Developer Suite 10.1.2.3 in Linux首先到oracle的技術支持下載所需補丁,然后1先打補丁7121788&#xff0c;把p7121788_10123_LINUX.zip解壓到/home/oracledev目錄下(ORACLE_HOME為/u01/app/oracledev/OraHome_dev)$cd /home/oracledev/7121788$expo…

java treemap_Java TreeMap HigherKey()方法與示例

java treemapTreeMap類HigherKey()方法 (TreeMap Class higherKey() method) higherKey() method is available in java.util package. HigherKey()方法在java.util包中可用。 higherKey() method is used to return the lowest key value element higher than the given key e…

centos配置ipv6地址

首先打開網站注冊一個賬號&#xff1a;http://www.tunnelbroker.net創建一個ipv6的地址&#xff1a;把下面的命令在linux上執行一遍&#xff0c;這個方式是臨時生效&#xff0c;重啟網卡和重啟系統自動失效。把上面的命令保存到一個配置文件中&#xff1a;vi /etc/sysconfig/ne…

php oracle 需要libmysql.dll么_,Windows7環境下Apache+PHP+MySQL完美配置

寫作此篇文章的目的在于記錄Windows 7環境下成功配置WAMP環境, 初學者在不使用整合好的WAMPServer和XAMPP的情況下徒手配置整合環境貌似有很多意想不到的問題. 這將是我們需要討論的.我將重現幾個經典的問題, 并一一排除. 希望對各位看官有點借鑒作用.一. Apache在整合PHP后無法…

stringreader_Java StringReader skip()方法與示例

stringreaderStringReader類skip()方法 (StringReader Class skip() method) skip() method is available in java.io package. skip()方法在java.io包中可用。 skip() method is used to skip the given number of characters in the stream. skip()方法用于跳過流中給定數量的…

NFS部署及優化(一)

NFS部署及優化&#xff08;一&#xff09;一、NFS的基本概念NFS network file system 網絡文件系統必然通過網絡通信來實現文件的訪問和寫入&#xff0c;所以做這個實驗的話最好有兩臺虛擬機配置:A&#xff1a;一個192.169.50.201為server端B&#xff1a;一個192.169.50.200為…

oracle 11g跳過壞塊,oracle 使用Dbms_Repair跳過壞塊

原博文&#xff1a;http://blog.chinaunix.net/uid-77311-id-3051382.html使用Dbms_Repair跳過壞塊步驟1:表tb_test中有壞塊(模擬壞塊同方法1)SQL> select count(1) from hxl.tb_test;select count(1) from hxl.tb_test*ERROR at line 1:ORA-01578: ORACLE data block corru…

strictmath_Java StrictMath nextUp()方法與示例

strictmathStrictMath類nextUp()方法 (StrictMath Class nextUp() method) Syntax: 句法&#xff1a; public static float nextUp(float fl);public static double nextUp(double do);nextUp() method is available in java.lang package. nextUp()方法在java.lang包中可用。…

并發數據結構-1.1 并發的數據結構的設計

原文鏈接&#xff0c;譯文鏈接&#xff0c;譯者&#xff1a;董明鑫&#xff0c;校對&#xff1a;周可人 隨著多個處理器共享同一內存的機器在商業上的廣泛使用&#xff0c;并發編程的藝術也產生了巨大的變化。當前的趨勢向著低功耗芯片級多線程&#xff08;CMT&#xff09;發展…

printstream_Java PrintStream close()方法與示例

printstreamPrintStream類close()方法 (PrintStream Class close() method) close() method is available in java.io package. close()方法在java.io包中可用。 close() method is used to close the underlying output stream. close()方法用于關閉基礎輸出流。 close() meth…

oracle底層執行順序,select語句結構與執行順序-Oracle

select語句結構與執行順序select語句的結構與執行順序&#xff0c;下面的序號代表執行順序8 SELECT (9)DISTINCT11 1 ROM 3   JOIN 2   ON 4 WHERE 5 GROUP BY 6 WITH {CUBE | ROLLUP}7 HAVING 10 ORDER BY 補…

HDU 4923 Room and Moor(瞎搞題)

瞎搞題啊。找出1 1 0 0這樣的序列&#xff0c;然后存起來&#xff0c;這樣的情況下最好的選擇是1的個數除以這段的總和。然后從前向后掃一遍。變掃邊進行合并。每次合并。合并的是他的前驅。這樣到最后從t-1找出的那條鏈就是最后滿足條件的數的大小。Room and Moor Time Limit:…

java define_Java Long類的define()方法與示例

java define長類解碼()方法 (Long class decode() method) decode() method is available in java.lang package. 在java.lang包中提供了define ()方法 。 decode() method is used to decode the given String value into a Long value. encode()方法用于將給定的String值解碼…

linux修改文件用戶組,linux命令 修改文件、文件夾所屬用戶、用戶組

最近學習hadoop&#xff0c;在替換配置文件的時候&#xff0c;發現老是報錯&#xff0c;沒有權限替換。我們知道如何改變文件的用戶組與擁有者了&#xff0c;那么&#xff0c;什么時候要使用chown或chgrp呢&#xff1f;或許你會覺得奇怪吧&#xff1f;是的&#xff0c;確實有時…

Kotlin 開篇

Kotlin 是一個基于 JVM 的新的編程語言&#xff0c;由 JetBrains 開發官網地址&#xff1a;http://kotlinlang.org。JetBrains&#xff0c;作為目前廣受歡迎的 Java IDE IntelliJ 的提供商&#xff0c;在 Apache 許可下已經開源其Kotlin 編程語言。開源地址&#xff1a;https:/…

inputstream示例_Java InputStream close()方法與示例

inputstream示例InputStream類close()方法 (InputStream Class close() method) close() method is available in java.io package. close()方法在java.io包中可用。 close() method is used to close this InputStream and free all system resources linked with this stream…

linux下的文件系統,Linux根文件系統(“/”文件系統)下的目錄介紹

Linux下的文件存儲與Windows完全不同&#xff0c;Windows將系統文件存儲在系統盤(比如說C:\下)Linux根本沒有盤符到概念只有一個根文件系/&#xff0c;各個磁盤分區掛載在/media/下(或者/mnt/下)/下到如/etc,/proc,/bin,/dev,lib等很是讓用慣了Windows的用戶不解&#xff0c;下…

greenlet 詳解

greenlet初體驗回到頂部Greenlet是python的一個C擴展&#xff0c;來源于Stackless python&#xff0c;旨在提供可自行調度的‘微線程’&#xff0c; 即協程。generator實現的協程在yield value時只能將value返回給調用者(caller)。 而在greenlet中&#xff0c;target.switch&am…

Java Calendar toString()方法與示例

日歷類toString()方法 (Calendar Class toString() method) toString() method is available in java.util package. toString()方法在java.util包中可用。 toString() method is used to string denotations of the calendar object. toString()方法用于對日歷對象的符號進行字…