且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从 java HashMap 获取不可变集合?

更新时间:2022-06-22 03:53:18

单个 API 调用无法做到这一点,您需要使用深度克隆.更改原始文件时不会更改克隆文件.之前在 SO 上已经讨论过这个话题,请参阅 如何克隆 ArrayList并克隆其内容?深度克隆实用程序推荐.

Its not possible to do this with a single API call, you need to utilize deep cloning. Clones won't be changed when you make changes to the original. This topic has been discussed on SO before, see How to clone ArrayList and also clone its contents? and Deep clone utility recomendation.