What is the Java equivalent of Objective-C#39;s NSDictionary?(Objective-C 的 NSDictionary 的 Java 等价物是什么?)
问题描述
Objective-C 的 NSDictionary
在 Java 中最接近的实现是什么?对我来说,它看起来像 HashMap<String, Object>
,但我对 Objective-C 很陌生.
What is the closest implementation of Objective-C's NSDictionary
in Java? To me, it looks like HashMap<String, Object>
, but I'm very new to Objective-C.
谢谢
推荐答案
NSDictionary
是一个类簇(参见 The Cocoa Fundamentals Guide),这意味着实际的实现对你是隐藏的,API用户.事实上,Foundation 框架会在运行时根据数据量等选择合适的实现.另外,NSDictionary
可以将任何 id
作为 key,而不仅仅是 NSString
(当然key对象的-hash
必须是常量).
NSDictionary
is a class cluster (see the "Class Cluster" section in The Cocoa Fundamentals Guide), meaning that the actual implementation is hidden from you, the API user. In fact, the Foundation framework will choose the appropriate implementation at run time based on amount of data etc. In addition, NSDictionary
can take any id
as a key, not just NSString
(of course, the -hash
of the key object must be constant).
因此,最接近的模拟可能是 Map
.
Thus, closest analog is probably Map<Object,Object>
.
这篇关于Objective-C 的 NSDictionary 的 Java 等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Objective-C 的 NSDictionary 的 Java 等价物是什么?


基础教程推荐
- 大摇大摆的枚举 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01