【发布时间】:2017-07-15 10:40:20
【问题描述】:
我知道java Set使用map作为内部数据结构来存储元素。但我想证明这一点。怎么证明?
https://www.javatpoint.com/q/7105/what-is-the-data-structure-that-a-set-uses-to-store-its-elements?
【问题讨论】:
-
向他们展示源代码。
-
你是怎么知道的?
-
注意
Set是一个接口..(源码见grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/…例子) -
例如,您可以查看HashSet 的源代码。在构造函数中,它创建了一个新的 HashMap 实例。
-
方便,代码已经存在
标签: java dictionary collections set