java treemap_Java TreeMap firstEntry()方法及示例

java treemap

TreeMap类的firstEntry()方法 (TreeMap Class firstEntry() method)

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

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

  • firstEntry() method is used to retrieve the key-value pairs linked with the lowest value key element that exists in this TreeMap.

    firstEntry()方法用于检索与此TreeMap中存在的最低值键元素链接的键值对。

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

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

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

    firstEntry()方法在返回条目时不会引发异常。

Syntax:

句法:

    public Map.Entry firstEntry();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

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

该方法的返回类型为Map.Entry ,它检索存在最低键元素的键值条目,否则当此TreeMap为“空白”时返回null。

Example:

例:

// Java program to demonstrate the example 
// of Map.Entry firstEntry() method of TreeMap 
import java.util.*;
public class FirstEntryOfTreeMap {
public static void main(String[] args) {
// Instantiates a TreeMap object
TreeMap < Integer, String > tree_map = new TreeMap < Integer, String > ();
// By using put() method is to add
// key-value pairs in a TreeMap
tree_map.put(10, "C");
tree_map.put(20, "C++");
tree_map.put(50, "JAVA");
tree_map.put(40, "PHP");
tree_map.put(30, "SFDC");
// Display TreeMap 
System.out.println("TreeMap: " + tree_map);
// By using firstEntry() method is to return
// the first entry with the least key value
// element exists in this TreeMap
System.out.println("tree_map.firstEntry(): " + tree_map.firstEntry());
}
}

Output

输出量

TreeMap: {10=C, 20=C++, 30=SFDC, 40=PHP, 50=JAVA}
tree_map.firstEntry(): 10=C

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

java treemap

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

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

相关文章

linux常用网络命令ping和arping

linux常用网络命令ping和arping ping 向目标主机发送icmp请求包 常用来测试当前主机与目标主机网络连接状况 常见选项 -c 设置发包的个数 -s 设置发的包的块大小&#xff0c;最大不超过65507 -W 设置接收回应超时时间 -i …

java printwriter实例_PrintWriter做过滤流+FileWriter案例分析

package com.mstf.ui;import java.io.*;public class TestWriter{public static void main(String args[]){//PrintWriter做过滤流FileWriter//doFilter1();//2、PrintWriter做过滤流OutputStreamWriter//doFilter2();//3、PrintWriter可以作为节点流//doNode();//4、PrintWrit…

treemap比较器_Java TreeMap比较器()方法与示例

treemap比较器TreeMap类的compare()方法 (TreeMap Class comparator() method) comparator() method is available in java.util package. 比较器()方法在java.util包中可用。 comparator() method is used to return the key element in this TreeMap based on the Comparator…

洛谷P1204 [USACO1.2]挤牛奶Milking Cows 前缀和

这题数据比较水 暴搜都能够过去 1 #include <cstdio>2 #include <cmath>3 #include <cstdlib>4 #include <algorithm>5 #include <string>6 #include <iostream>7 #include <iomanip>8 #include <cstring>9 using namespace s…

java script创建对象_JavaScript七种非常经典的创建对象方式

JavaScript创建对象的方式有很多&#xff0c;通过Object构造函数或对象字面量的方式也可以创建单个对象&#xff0c;显然这两种方式会产生大量的重复代码&#xff0c;并不适合量产。接下来介绍七种非常经典的创建对象的方式&#xff0c;他们也各有优缺点。一、工厂模式可以无数…

java 方法 示例_Java扫描仪具有示例的NextNextInt()方法

java 方法 示例扫描器类的hasNextInt()方法 (Scanner Class hasNextInt() method) Syntax: 句法&#xff1a; public boolean hasNextInt();public boolean hasNextInt(int rad);hasNextInt() method is available in java.util package. hasNextInt()方法在java.util包中可用…

axis2开发webservice之编写Axis2模块(Module)

axis2中的模块化开发。能够让开发者自由的加入自己所需的模块。提高开发效率&#xff0c;减少开发的难度。 Axis2能够通过模块&#xff08;Module&#xff09;进行扩展。Axis2模块至少须要有两个类&#xff0c;这两个类分别实现了Module和Handler接口。开发和使用一个Axis2模块…

java 看书浏览器官_JAVA读取文件流,设置浏览器下载或直接预览操作

最近项目需要在浏览器中通过url预览图片。但发现浏览器始终默认下载&#xff0c;而不是预览。研究了一下&#xff0c;发现了问题&#xff1a;// 设置response的header&#xff0c;注意这句&#xff0c;如果开启&#xff0c;默认浏览器会进行下载操作&#xff0c;如果注释掉&…

Java PriorityQueue poll()方法与示例

PriorityQueue类poll()方法 (PriorityQueue Class poll() method) poll() method is available in java.util package. poll()方法在java.util包中可用。 poll() method is used to return the first element with removing an element from this PriorityQueue. poll()方法用于…

scrapy抓取淘宝女郎

scrapy抓取淘宝女郎 准备工作 首先在淘宝女郎的首页这里查看&#xff0c;当然想要爬取更多的话&#xff0c;当然这里要查看翻页的url,不过这操蛋的地方就是这里的翻页是使用javascript加载的&#xff0c;这个就有点尴尬了&#xff0c;找了好久没有找到&#xff0c;这里如果有朋…

map在Java集合_java集合之Map

MapMap用于保存具有映射关系的数据。Map中key不允许重复&#xff0c;value可以重复&#xff0c;key和value之间存在单向一对一关系HashMap和Hashtable区别1 Hashtable线程安全、HashMap线程不安全&#xff0c;所以HashMap性能高一点2 Hashtable不允许用null做key和value&#x…

Java OutputStream close()方法与示例

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

怎样在fastboot 里面加入新的命令

fastboot 是android 默认的一种debug 方法。它的优点是在进入linux kernel 之前就可以操作。默认fastboot 支持的命令&#xff1a; usage: fastboot [ <option> ] <command>commands: update <filename> reflash device …

java编写字符串连接程序注释_Java 注解自动化处理对应关系实现注释代码化

public class EsQuery { private static int DEFAULT_SIZE 100; private final Map termFilter;private final Map rangeFilter;private final Map matchFilter;private int size;private String orderBy null;private String order null; // query 查询语法, 是否需要 filtere…

getlanguage_Java语言环境getLanguage()方法与示例

getlanguage区域设置类getLanguage()方法 (Locale Class getLanguage() method) getLanguage() method is available in java.util package. getLanguage()方法在java.util包中可用。 getLanguage() method is used to retrieve this Locale language code and the language co…

[转]Anaconda

安装 Anaconda Anaconda 可用于 Windows、Mac OS X 和 Linux。可以在 https://www.continuum.io/down... 上找到安装程序和安装说明。 如果计算机上已经安装了 Python&#xff0c;这不会有任何影响。实际上&#xff0c;脚本和程序使用的默认 Python 是 Anaconda 附带的 Python。…

win10 iot core java_Windows 10 IoT Core 正式版初体验

今天收到Windows 10 IoT Core Team邮件&#xff0c;Windows 10 IoT Core正式发布。以下记录了今天在Raspberry Pi 2上的体验过程&#xff1a;准备工作一台运行着正版Windows 10且版本不小于10240的个人PCVisual Studio 2015 版本不小于14.0.23107.0 D14Rel Install Visual Stud…

filterwriter_Java FilterWriter flush()方法与示例

filterwriterFilterWriter类flush()方法 (FilterWriter Class flush() method) flush() method is available in java.io package. flush()方法在java.io包中可用。 flush() method is used to flush out the string from this FilterWriter stream. flush()方法用于从此Filter…

VUE2 第五天学习--过渡效果

阅读目录 1.理解VUE---过渡效果回到顶部1.理解VUE---过渡效果 1. 过渡的-css-类名会有4个(css) 类名在 enter/leave 在过渡中切换。1. v-enter: 进入过渡的开始状态。在元素被插入时生效&#xff0c;在下一个帧移除。2. v-enter-active: 进入过渡的结束状态。在元素被插入时生效…

java 集合addall_Java集合的addAll()方法和示例

java 集合addall集合类的addAll()方法 (Collections Class addAll() method) addAll() Method is available in java.lang package. addAll()方法在java.lang包中可用。 addAll() Method is used to put all the given elements(ele) to the given collection (co). addAll()方…