weakhashmap

WeakHashMap类的get()方法 (WeakHashMap Class get() method)

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

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

  • get() method is used to get the value to which the given key element (key_ele) associated in this map otherwise it returns null.

    get()方法用于获取与此映射中关联的给定键元素(key_ele)关联的值,否则返回null。

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

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

  • get() method does not throw an exception at the time of returning the value of the given key element (key_ele).

    返回给定键元素(key_ele)的值时, get()方法不会引发异常。

Syntax:

句法:

    public Object get(Object key_ele);

Parameter(s):

参数:

  • Object key_ele – represents the key element (key_ele) whose mapping is to be retrieved.

    对象key_ele –表示要检索其映射的键元素(key_ele)。

Return value:

返回值:

The return type of the method is Object, it returns key element (key_ele) value when it exists otherwise it returns null.

该方法的返回类型为Object ,如果存在则返回键元素(key_ele)的值,否则返回null。

Example:

例:

// Java program to demonstrate the example
// of Object get(Object key_ele) method of WeakHashMap
import java.util.*;
public class GetOfWeakHashMap {public static void main(String[] args) {// Instantiates a WeakHashMap object
Map < Integer, String > map = new WeakHashMap < Integer, String > ();
// By using put() method is to add
// key-value pairs in a WeakHashMap
map.put(10, "C");
map.put(20, "C++");
map.put(50, "JAVA");
map.put(40, "PHP");
map.put(30, "SFDC");
// Display WeakHashMap
System.out.println("WeakHashMap: " + map);
// By using get() method is to return
// the value associated for the given
// key element exists in this WeakHashMap
Object val_ele = map.get(50);
// Display val_ele
System.out.print("map.get(50): ");
System.out.println(val_ele);
}
}

Output

输出量

WeakHashMap: {30=SFDC, 40=PHP, 10=C, 20=C++, 50=JAVA}
map.get(50): JAVA

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

weakhashmap

weakhashmap_Java WeakHashMap get()方法与示例相关推荐

  1. .net连接mysql数据_.net连接MYSQL数据库的方法及示例!

    连接MYSQL数据库的方法及示例 方法一: 使用MYSQL推出的MySQL Connector/Net is an ADO.NET driver for MySQL 该组件为MYSQL为ADO.NET ...

  2. set.difference() 的用法(python3)_Python 集合 difference_update() 使用方法及示例

    Python 集合 difference_update() 使用方法及示例 Difference_update()使用集合的差集更新集合,并调用difference_update()方法. 如果A和B ...

  3. doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例

    本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...

  4. isdigit函数在C语言什么意思,C 库函数 isdigit() 使用方法及示例

    C 库函数 isdigit() 使用方法及示例 isdigit()函数检查字符是否为数字字符(0-9). isdigit()的函数原型int isdigit( int arg ); 函数isdigit ...

  5. python中append的用法_Python 列表 append() 使用方法及示例

    Python 列表 append() 使用方法及示例 append()方法将一个项目添加到列表的末尾. append()方法将单个项目添加到列表的末尾. append()方法的语法为:list.app ...

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

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

  7. python文件的用法,Python 文件 readlines() 使用方法及示例

    Python 文件 readlines() 使用方法及示例 概述 readlines() 方法用于读取所有行(直到结束符 EOF)并返回列表,该列表可以由 Python 的 for... in ... ...

  8. php一些单选、复选框的默认选择方法(示例)

    转载 http://www.php.cn/php-weizijiaocheng-360029.html 一. radio和checkbox及php select默认选择的实现代码 1.radio单选框 ...

  9. java math round小数_Java Math round() 使用方法及示例

    Java Math round() 使用方法及示例 Java Math round()方法将指定的值四舍五入为最接近的int或long值,然后将其返回. 也就是说,1.2四舍五入为1,1.8四舍五入为 ...

  10. java linkedlist 方法_Java LinkedList getFirst()方法与示例

    LinkedList getFirst()方法 (LinkedList getFirst() method) This method is available in package java.util ...

最新文章

  1. Ratatosk - Hybrid error correction of long reads enables accurate variant calling and assembly
  2. 阿里员工在用的黑科技 今年云栖要公开了!
  3. C++ 的语言杂谈(一)--C++不是新手友好的
  4. Django之orm查询
  5. vue watch 第一次不执行_Vue 实现前进刷新,后退不刷新的效果
  6. 排序算法之两路归并排序(Java)
  7. java字节流转字符串_字节流与字符流的区别及相互转换
  8. 封装mysql数据库_快速掌握 Mysql数据库对文件操作的封装
  9. java 开发平台下载,JAVA开发平台和JAVA开发工具下载
  10. 一段仿真PE加载器行为的程序
  11. 【文献阅读】2004 Goktekin NS方程加弹性 A Method for Animating Viscoelastic Fluids
  12. 服务器性能监控主要内容,主要服务器的各项指标监控
  13. 计算机主板pci插槽,什么是PCI插槽 PCI-E插槽如何辨别【详解】
  14. Windows文件共享防火墙规则设置
  15. keyshot聚光灯_KeyShot 6使用技巧
  16. 精心整理了30个Python数据分析项目,拿走就用!
  17. 公用Foot和友情链接模块代码模板
  18. AI药物设计与新药先导化合物筛选
  19. 初高中英语老师教师资格证考试成功通过前辈备考经验分享
  20. 腾讯测试“过来人”告诉你,到达瓶颈期如何提升自己

热门文章

  1. linux 脚本批量删除,Linux Shell使用Bash脚本批量删除文件
  2. html如何设置鼠标选中状态,怎么用CSS 设置 当鼠标移动到菜单时,该按钮变色,鼠标点击后,页面停留在鼠标滑过时的状态!!很急!...
  3. 统计内存使用率shell
  4. Mac使用Homebrew安装Kafka
  5. 前端错误日志收集方案
  6. python练习笔记——利用信号signal处理僵尸进程
  7. opengl es的射线拾取
  8. HoughLine变换
  9. FileSystemObject和Folders使用详细介绍
  10. python call agilent com_PyVISA通过RS232(USB)与安捷伦34970A通信时出现超时错误