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 等价物是什么?
基础教程推荐
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
