(Include clojure.jar in your lib path)
List list = new PersistentList("t1");
try {
list.add("t2");
} catch (UnsupportedOperationException e) {
System.out.println("It seems that this operation is not supported.");
}
System.out.println("List size: " + list.size());
Map map = new PersistentArrayMap(new Object[]{"key1", "value1"});
try {
map.put("key2", "value2");
} catch (UnsupportedOperationException e) {
System.out.println("It seems that this operation is not supported.");
}
System.out.println("Map size: " + map.size());
This can be used as an alternative for
java.util.Collections.unmodifiableList(…)
Advertisement