java treemap_Java TreeMap pollFirstEntry()方法与示例

java treemap

TreeMap类pollFirstEntry()方法 (TreeMap Class pollFirstEntry() method)

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

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

  • pollFirstEntry() method is used to return and then remove the entry (key-value pair) linked with the lowest key element value that exists in this TreeMap.

    pollFirstEntry()方法用于返回,然后删除与此TreeMap中存在的最低键元素值链接的条目(键值对)。

  • pollFirstEntry() 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.

    pollFirstEntry()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名访问该方法,则会收到错误消息。

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

    返回第一个条目时, pollFirstEntry()方法不会引发异常。

Syntax:

句法:

    public Map.Entry pollFirstEntry();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is Map.Entry, it retrieves an entry with the lowest key element value when exists otherwise it returns null.

该方法的返回类型为Map.Entry ,如果存在,则检索具有最低键元素值的条目,否则返回null。

Example:

例:

// Java program to demonstrate the example 
// of Map.Entry pollFirstEntry () 
// method of TreeMap 
import java.util.*;
public class PollFirstEntryOfTreeMap {
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 pollFirstEntry() method is to
// return and remove the key-value pairs
// linked with the least key element value
// i.e. "1"
tm.pollFirstEntry();
// Display updated TreeMap tm
System.out.println("tm.pollFirstEntry(): " + tm);
}
}

Output

输出量

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

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

java treemap

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/544919.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

各大厂面试高频的面试题新鲜出炉,你能答上几道?

关于生产环境如何配置线程数&#xff0c;还是要根据业务来进行区分&#xff0c;我们时常会听到什么IO密集型、CPU密集型任务...那么这里提一个问题&#xff1a;大家知道什么样的任务或者代码会被认定为IO/CPU密集&#xff1f;又是用什么样的标准来认定IO/CPU密集&#xff1f;如…

c/c++如何获取数组的长度

2019独角兽企业重金招聘Python工程师标准>>> C、C中没有提供 直接获取数组长度的函数&#xff0c;对于存放字符串的字符数组提供了一个strlen函数获取长度&#xff0c;那么对于其他类型的数组如何获取他们的长度呢&#xff1f;其中一种方法是使 用sizeof(array) / s…

JSP JAVA 自定义 错误页面(404,505,500)

当网站页面找不到或者服务器内部出错的时候&#xff0c;我们不想让用户看到默认的那张 404&#xff0c;500 的错误页面&#xff0c;那要是想自己做一张 找不到页面的页面改怎么做呢&#xff1f;在 web .xml 文件中 加入下面的语句就能达到这个效果<error-page><error-…

【送给读者】全新苹果 AirPods,包邮送一套!

为回馈长期以来科创人读者对本栏目的关注支持&#xff0c;本周小编联合了计算机领域八位高质量原创号主一起为大家送出一套 全新苹果AirPods 2代。以下推荐的公号原创率都很高&#xff0c;均为个人IP号&#xff0c;有些小伙伴应该已经关注部分公号。本次抽奖采用第三方抽奖小程…

java 方法 示例_Java扫描仪的hasNextBoolean()方法与示例

java 方法 示例扫描器类的hasNextBoolean()方法 (Scanner Class hasNextBoolean() method) hasNextBoolean() method is available in java.util package. hasNextBoolean()方法在java.util包中可用。 hasNextBoolean() method is used to check whether this Scanners next in…

进程控制(kill)

为什么80%的码农都做不了架构师&#xff1f;>>> kill&#xff1a;终止进程&#xff08;或传送信号到某进程&#xff09; kill [options] [process_ids] kill命令可以发送信号给进程&#xff0c;可以终止&#xff08;terminate&#xff09;&#xff08;默认操作&a…

oracle怎样修改表名、列名、字段类型、添加表列、删除表列

ALTER TABLE SCOTT.TEST RENAME TO TEST1--修改表名 ALTER TABLE SCOTT.TEST RENAME COLUMN NAME TO NAME1 --修改表列名 ALTER TABLE SCOTT.TEST MODIFY NAME1 NUMBER(20) --修改字段类型 ALTER TABLE SCOTT.TEST ADD ADDRESS VARCHAR2(40) --添加表列 ALTER TABLE SCOTT.TEST…

TextArea里Placeholder换行问题

转&#xff1a;http://www.tuicool.com/articles/feYVNf 页面上使用TextArea控件时&#xff0c;会时不时的想给个提示&#xff0c;比如按照一定方式操作之类的。 正常情况下&#xff0c;会使用Placeholder&#xff0c;但这样的提示是不会换行的&#xff0c;无论是用\r\n&…

printstream_Java PrintStream clearError()方法与示例

printstreamPrintStream类clearError()方法 (PrintStream Class clearError() method) clearError() method is available in java.io package. clearError()方法在java.io包中可用。 clearError() method is used to clear the internal error state of this PrintStream. cle…

uniq用法详解

uniquniq命令可以去除排序过的文件中的重复行&#xff0c;因此uniq经常和sort合用。也就是说&#xff0c;为了使uniq起作用&#xff0c;所有的重复行必须是相邻的。uniq语法[rootwww ~]# uniq [-icu]选项与参数&#xff1a;-i &#xff1a;忽略大小写字符的不同&#xff1b;-…

Swagger增强神器:Knife4j!用它轻松实现接口搜索、Word下载、接口过滤...

视频版内容&#xff1a;Swagger 是开发中最常用的框架之一了&#xff0c;但 Swagger 本身又有很多不完善的地方&#xff0c;比如&#xff0c;在众多的接口中查询某一个接口&#xff0c;又或者是把所有的接口导出成 Word 格式等&#xff0c;都无法在 Swagger 中实现。有人可能会…

tohexstring方法_Java Long类toHexString()方法的示例

tohexstring方法长类toHexString()方法 (Long class toHexString() method) toHexString() method is available in java.lang package. toHexString()方法在java.lang包中可用。 toHexString() method is used to represent a hexadecimal string of the given parameter [val…

关于显示和隐藏DIV标签

document.getElementById("DIV的ID").style.display"none";//隐藏 document.getElementById("DIV的ID").style.display"block";//显示

7种可能会导致内存泄漏的场景!

虽然Java程序员不用像C/C程序员那样时刻关注内存的使用情况&#xff0c;JVM会帮我们处理好这些&#xff0c;但并不是说有了GC就可以高枕无忧&#xff0c;内存泄露相关的问题一般在测试的时候很难发现&#xff0c;一旦上线流量起来可能马上就是一个诡异的线上故障。1. 内存泄露的…

logstash 过虑nginx访问日志

标题是不是可以翻译成这样&#xff1a;logstash Filters nginx access log好了&#xff0c;进入正题&#xff0c;日志管理服务器我用ElasticSearchLogStashKibanaRedis先说下我的架构&#xff1a;远程NGINX采集日志数据到REDISlogstashelasticsearchkibana服务器至于怎么部署&a…

java 方法 示例_Java语言环境getISOLanguages()方法与示例

java 方法 示例区域设置类getISOLanguages()方法 (Locale Class getISOLanguages() method) getISOLanguages() method is available in java.util package. getISOLanguages()方法在java.util包中可用。 getISOLanguages() method is used to return an array of string that …

struts2显示列表序号的办法

http://blog.knowsky.com/226680.htm 有的时候需要在页面上进行计算&#xff0c;比如要显示十条数据并且十条数据前要有显示123456……的序号&#xff0c;解决这个问题有两种办法。第一种是通过set标签实现&#xff1a; <s:set name"a" value1/> <s:ite…

Spring中的重试功能!嗯,有点东西

来源&#xff1a;https://albenw.github.io/posts/69a9647f/概要Spring实现了一套重试机制&#xff0c;功能简单实用。Spring Retry是从Spring Batch独立出来的一个功能&#xff0c;已经广泛应用于Spring Batch,Spring Integration, Spring for Apache Hadoop等Spring项目。 本…

关于Shell的一些常用命令

2019独角兽企业重金招聘Python工程师标准>>> ls -lat 列出当前目录所有东东的东东 ls -lath 人看的大小 ls -F | grep "/$"只搞目录 ls -lR 包括子目录… ls --ignore filename -lt 忽略某个 which&#xff0c;在PATH变量指定的路径中&#xff0c;搜索看某…

linkedhashset_Java LinkedHashSet contains()方法与示例

linkedhashsetLinkedHashSet类contains()方法 (LinkedHashSet Class contains() method) contains() method is available in java.util package. contains()方法在java.util包中可用。 contains() method is used to check whether the given object (ob) exists or not exist…