博文

目前显示的是标签为“collections”的博文

Java properties and synchronize/unmodifiable collections

Properties Class:   Is a persistent Hashtable that store key-value pairs of Strings. Properties are intended to use for user accessable file of application preferences. EX of P: private Properties table; table = new properties(); table.setProperty("color","red"); table.setProperty("size","200"); Some useful method: FileOutputStream output = new FileOutputStream("props.dat"); table.store(output,"sample properties"); FileInputStream input = new FileInputStream("props.dat"); table.load(input); table.getProperty(Strint(key)); table.clear(); Synchronized Collections: EX: List list1 = new ArrayList (); List list2 = Collections.synchronizedList(list1); //static method provide a wrapper synchornized object Unmodifiable collecitons: EX: List list1 = new ArrayList (); List list2 = Collections.unmodifiableList(list1); //unmodifiable wrapper to create a collection taht offers read-only access to others 中...