Collections.unmodifiableSet()
二、 Collections的unmodifiableSet方法
Collections的unmodifiableXXX方法设定一个Collection或Map为只读,有四中类型,分别对应
Collection、List、Set、Map。他只有一个参数,一般的写法会是这样:
Set set = new HashSet();
.....
set = Collections.unmodifiableSet(set);
此时如果你对容器实施写操作的话,会抛出UnsupportedOperationException。当然你可像
DisplaySetting一样,并不把容器本身的引用设为只读,而是提供给外部的接口的引用为只读。当然
可以自己提供一个私有的方法得到该引用,然后只允许自己对容器的内容修改。初看时感到很奇怪:
private static final Set all = new HashSet();
public static final Set ALL = Collections.unmodifiableSet(all);
分享到:
相关推荐
commons-collections-20040616.jar, commons-collections-3.2-osgi.jar, commons-collections-3.2-sources.jar, commons-collections-3.2.1.jar, commons-collections-3.2.2-javadoc.jar, commons-collections-3.2.2...
赠送jar包:commons-collections-3.2.2.jar; 赠送原API文档:commons-collections-3.2.2-javadoc.jar; 赠送源代码:commons-collections-3.2.2-sources.jar; 赠送Maven依赖信息文件:commons-collections-3.2.2....
赠送jar包:commons-collections4-4.4.jar; 赠送原API文档:commons-collections4-4.4-javadoc.jar; 赠送源代码:commons-collections4-4.4-sources.jar; 赠送Maven依赖信息文件:commons-collections4-4.4.pom;...
赠送jar包:commons-collections4-4.1.jar; 赠送原API文档:commons-collections4-4.1-javadoc.jar; 赠送源代码:commons-collections4-4.1-sources.jar; 赠送Maven依赖信息文件:commons-collections4-4.1.pom;...
赠送jar包:commons-collections4-4.4.jar; 赠送原API文档:commons-collections4-4.4-javadoc.jar; 赠送源代码:commons-collections4-4.4-sources.jar; 赠送Maven依赖信息文件:commons-collections4-4.4.pom;...
该文件里包含两个.jar包: collections-generic-4.01.jar和looks-2.1.4.jar, 引入collections-generic-4.01.jar: 右击工程--》Build path ——》Add External JAR-->选中collections-generic-4.01.jar --》OK 在源...
赠送jar包:commons-collections-3.2.2.jar; 赠送原API文档:commons-collections-3.2.2-javadoc.jar; 赠送源代码:commons-collections-3.2.2-sources.jar; 赠送Maven依赖信息文件:commons-collections-3.2.2....
apache-common系列中的重要的成员:apache-common-collections。包中对Java中的集合类进行了一定的补充,定义了一些全新的集合,当然也是实现了Collection接口的,比如Bag,BidiMap。同时拥有新版本的原有集合,比如...
赠送jar包:commons-collections-3.2.1.jar; 赠送原API文档:commons-collections-3.2.1-javadoc.jar; 赠送源代码:commons-collections-3.2.1-sources.jar; 包含翻译后的API文档:commons-collections-3.2.1-...
赠送jar包:commons-collections-3.2.1.jar 赠送原API文档:commons-collections-3.2.1-javadoc.jar 赠送源代码:commons-collections-3.2.1-sources.jar 包含翻译后的API文档:commons-collections-3.2.1-...
赠送jar包:eclipse-collections-forkjoin-7.1.2.jar; 赠送原API文档:eclipse-collections-forkjoin-7.1.2-javadoc.jar; 赠送源代码:eclipse-collections-forkjoin-7.1.2-sources.jar; 赠送Maven依赖信息文件:...
赠送jar包:commons-collections4-4.1.jar; 赠送原API文档:commons-collections4-4.1-javadoc.jar; 赠送源代码:commons-collections4-4.1-sources.jar; 赠送Maven依赖信息文件:commons-collections4-4.1.pom;...
赠送jar包:eclipse-collections-7.1.2.jar; 赠送原API文档:eclipse-collections-7.1.2-javadoc.jar; 赠送源代码:eclipse-collections-7.1.2-sources.jar; 赠送Maven依赖信息文件:eclipse-collections-7.1.2....
commons-collections4-4.2-bin commons下的collections包
commons-collections4-4.1,用来修复java反序列漏洞,重命名后替换之前Middleware\modules下的的3.2.0版
commons-collections-3.2.1-bin
Apache Commons Collections 4.2、可重用的java工具包。
java读取excel2007解决org.apache.commons.collections找不到的问题。