一位面试官问我这个问题是在不使用集合 API 方法的情况下在 java 中创建一个只读列表。关于我们如何实现这一点有什么想法吗?
最佳答案
只需扩展AbstractList
.正如文档中提到的:
To implement an unmodifiable list, the programmer needs only to extend this class and provide implementations for the get(int) and size() methods.
关于java - 如何在不使用集合 API 中的不可修改列表方法的情况下在 Java 中创建只读列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45364547/