java enummap

EnumMap类containsKey()方法 (EnumMap Class containsKey() method)

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

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

  • containsKey() method is used to check whether this map has values for the given key element (key_ele) of this enum map.

    containsKey()方法用于检查此映射是否具有此枚举映射的给定键元素( key_ele )的值。

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

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

  • containsKey() method does not throw an exception at the time of checking key mappings.

    在检查键映射时, containsKey()方法不会引发异常。

Syntax:

句法:

    public boolean containsKey(Object key_ele);

Parameter(s):

参数:

  • Object key_ele – represents the key element (key_ele) whose presence is to be checked.

    对象key_ele –表示要检查其存在的关键元素(key_ele)。

Return value:

返回值:

The return type of this method is boolean, it returns true when this enum map have any value for the given key element (key_ele) otherwise it returns false.

此方法的返回类型为boolean ,当此枚举映射具有给定键元素(key_ele)的任何值时,它返回true,否则返回false。

Example:

例:

// Java program to demonstrate the example
// of boolean containsKey(Object key_ele) method of EnumMap
import java.util.*;
public class ContainsKeyOfEnumMap {public enum Colors {RED,
BLUE,
PINK,
YELLOW
};
public static void main(String[] args) {// We are creating EnumMap object
EnumMap < Colors, String > em =
new EnumMap < Colors, String > (Colors.class);
// By using put() method is to
// add the linked values in an EnumMap
em.put(Colors.RED, "1");
em.put(Colors.BLUE, "2");
em.put(Colors.PINK, "3");
em.put(Colors.YELLOW, "4");
// Display EnumMap
System.out.println("EnumMap :" + em);
// By using containsKey() method isto
// check whether this EnumMap contains
// any value for the given key element
// in an EnumMap
boolean status = em.containsKey(Colors.PINK);
// Display status of EnumMap
System.out.println("em.containsKey(Colors.PINK): " + status);
}
}

Output

输出量

EnumMap :{RED=1, BLUE=2, PINK=3, YELLOW=4}
em.containsKey(Colors.PINK): true

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

java enummap

java enummap_Java EnumMap containsKey()方法与示例相关推荐

  1. java散列法的运用实例,Java HashMap compute() 使用方法及示例

    Java HashMap compute() 使用方法及示例 Java HashMap compute()方法计算一个新值,并将其与哈希映射中的指定键相关联. compute()方法的语法为: has ...

  2. math的用法在java中的使用,Java Math cbrt() 使用方法及示例

    Java Math cbrt() 使用方法及示例 Java Math cbrt()方法返回指定数字的立方根. cbrt()方法的语法为: Math.cbrt(double num) 注意:cbrt() ...

  3. java arraylist 方法返回值,Java ArrayList get() 使用方法及示例

    Java ArrayList get() 使用方法及示例 Java ArrayList get()方法返回指定位置存在的元素. get()方法的语法为: arraylist.get(int index ...

  4. java enummap_Java EnumMap size()方法与示例

    java enummap EnumMap类的size()方法 (EnumMap Class size() method) size() method is available in java.util ...

  5. java enummap_Java EnumMap get()方法与示例

    java enummap EnumMap类的get()方法 (EnumMap Class get() method) get() method is available in java.util pa ...

  6. java enummap_Java EnumMap values()方法与示例

    java enummap EnumMap类values()方法 (EnumMap Class values() method) values() method is available in java ...

  7. java enummap_Java EnumMap containsValue()方法与示例

    java enummap EnumMap类containsValue()方法 (EnumMap Class containsValue() method) containsValue() method ...

  8. containskey java_Java Hashtable containsKey()方法与示例

    哈希表类containsKey()方法containsKey()方法在java.util包中可用. containsKey()方法用于检查给定对象是否为键元素(key_ele). containsKe ...

  9. java kryo_Kryo框架使用方法代码示例

    Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...

最新文章

  1. validating和validated的区别
  2. requests 两种传参方式
  3. java linux 面试题_java 面试题
  4. ML之分类预测之LARS:利用回归工具将二分类转为回归问题并采用LARS算法构建分类器
  5. 真是一分钱一分货 NVme SSD都有哪些优势?
  6. .jsp后缀语言_ARM汇编语言入门(三)
  7. 转载--html显示当前时间
  8. 计算机专业专业课代号408,计算机专业考研你一定要知道的事情!
  9. jupyter可以打开HTML文件吗,Jupyter ~ 像写文章般的 Coding (附:同一个ipynb文件,执行多语言代码)...
  10. ruby hash方法_Hash.fetch()方法以及Ruby中的示例
  11. python做线性回归统计推断提取参数_概率分析方法与推断统计(来自我写的python书)...
  12. 如何快速打好java基础_学习Java课程时如何才能打好基础呢?
  13. [转]Centos 安装Sublime text 3
  14. 调用sap函数接口_部署在SAP云平台CloudFoundry环境的应用如何消费SAP Leonardo机器学习API...
  15. 下载网页中的html5视频之手动方法
  16. 基于Springboot实现汽车4S店销售管理系统
  17. ttl接地是高电平还是低电平_说明图3.12中各门电路的输出是高电平还是低电平。已知它们都是74HC系列的CMOS电路 简单的逻辑门电路 判断各门电路...
  18. kali linux 最新下载,kali新版本下载,Kali Linux 2019.4 开放下载
  19. matlab nlm,NLM.m · hr_yang/MatlabCode - Gitee.com
  20. 2021年危险化学品经营单位安全管理人员考试报名及危险化学品经营单位安全管理人员最新解析

热门文章

  1. 云服务器带宽如何计算,云服务器怎么选择带宽
  2. html 文本框 自动拼接,HTML 中table的结构以及拼接
  3. ant-design官网打不开 , 需要用镜像地址打开
  4. NodeJS学习笔记—1.CommonJS规范
  5. 4. HTML表单标签
  6. mongoose中的populate之多级填充,嵌套字段填充?
  7. 【DeepLearning】Exercise:Learning color features with Sparse Autoencoders
  8. Automatic Reference Counting
  9. (扩展)欧几里德快速幂
  10. 在查询的结果中添加自增列 两种方法