weakhashmap

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

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

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

  • keySet() method is used to retrieve all the key exists in this map to be viewed in a set.

    keySet()方法用于检索此映射中存在的所有键,以在集合中进行查看。

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

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

  • keySet() method does not throw an exception at the time of viewing elements in a set.

    在查看集合中的元素时, keySet()方法不会引发异常。

Syntax:

句法:

    public Set keySet();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is Set, it returns existing keys in this map to be viewed in a set.

该方法的返回类型为Set ,它返回此映射中的现有键以在集合中查看。

Example:

例:

// Java program to demonstrate the example
// of Set keySet() method of WeakHashMap
import java.util.*;
public class KeySetOfWeakHashMap {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 keySet() method is to
// return the set of of keys exists
// in this WeakHashMap to be viewed in a Set
Set s = map.keySet();
// Display status
System.out.print("map.keySet(): ");
System.out.println(s);
}
}

Output

输出量

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

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

weakhashmap

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

  1. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  2. java json keyset_Java JsonObject.keySet方法代码示例

    import javax.json.JsonObject; //导入方法依赖的package包/类 private JsonObject getRatings(Cookie user, String ...

  3. Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法 (ResourceBundle Class keySet() method) keySet() method is available in jav ...

  4. Java IdentityHashMap keySet()方法及示例

    IdentityHashMap类keySet()方法 (IdentityHashMap Class keySet() method) keySet() method is available in j ...

  5. java treemap_Java TreeMap keySet()方法与示例

    java treemap TreeMap类的keySet()方法 (TreeMap Class keySet() method) keySet() method is available in jav ...

  6. Java Hashtable keySet()方法与示例

    哈希表类keySet()方法 (Hashtable Class keySet() method) keySet() method is available in java.util package. ...

  7. getenv java_Java System类getenv()方法及示例

    系统类getenv()方法getenv()方法在java.lang包中可用. getenv()方法用于返回键值对中当前环境变量的不可修改Map. 我们将看到什么是环境变量?环境变量是系统相关的外部命名 ...

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

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

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

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

最新文章

  1. 端口基础常识大全+常用端口对照
  2. 海底声纳Sonar探测编辑软件开发纪事
  3. java爬虫下载付费html网页模板
  4. Highcharts X轴名称太长,如何设置下面这种样式
  5. 3-2 文件夹类Directory的常用方法(2)
  6. 安卓关于图片压缩的那些事儿,希望给每个安卓开发人员一些帮助
  7. python批量读取图片并批量保存_Python实现批量读取图片并存入mongodb数据库的方法示例...
  8. pythoncookbook和流畅的python对比_为什么你学Python效率比别人慢?因为你没有这套完整的学习资料...
  9. 阿里程序员双11加班吃什么?
  10. vi+ctags 阅读源码
  11. 模拟集成电路设计(拉扎维)第三章学习笔记
  12. 笔记本W10找不到端口(com口)及单片机串口连接的问题(附51开发板的CH340串口芯片的驱动程序安装包)
  13. 51单片机(AT89S52)设计简单计算器(4位加减乘除)
  14. 【docker-ce】k8s集群docker容器异常重启问题分析
  15. 数据结构例9.编写一个算法,将带头结点的单向链表 拆分成一个奇数链表和一个偶数链表,并分别输出
  16. 骨传导耳机品牌排行榜前十,目前最好用的几款推荐
  17. 怎么撰写一份优秀的数据分析报告(五)
  18. kermit配置文件
  19. mysql组合索引,abc索引命中
  20. 有多远滚多远 html5游戏,68微信游戏有多远滚多远怎样能得高分

热门文章

  1. 4n35光耦引脚图_光耦继电器的主要特点以及输入特性!先进光半导体
  2. datastage 使用小结
  3. 在Python中定义和使用抽象类的方法
  4. SIPp web frontend(2)
  5. 精华阅读第6期|程序猿的世界,你不懂!
  6. Codeforces Round #FF
  7. openssl漏洞检查
  8. iphone开发之C++和Objective-C混编
  9. LVM( Logical Volume Manager )配置案例(on RHEL4)
  10. 初学 Delphi 嵌入汇编[29] - 寄存器所能接受的数值范围