- properties是一个Map体系的集合类
- public class Properties extends Hashtable
- 为什么在IO流部分学习Properties
- Properties中有跟IO相关的方法
- 当做双列集合使用
- 不需要加泛型 , 工作中只存字符串
public class PropertiesDemo1 {public static void main(String[] args) {// 创建集合对象Properties properties = new Properties();// 添加元素properties.put("it001" , "张三");properties.put("it002" , "李四");properties.put("it003" , "王五");// 遍历集合 : 键找值Set<Object> set = properties.keySet();for (Object key : set) {System.out.println(key + "---" + properties.get(key)); } System.out.println("========================");// 遍历集合 : 获取对对象集合 , 获取键和值Set<Map.Entry<Object, Object>> set2 = properties.entrySet(); for (Map.Entry<Object, Object> entry : set2) {Object key = entry.getKey();Object value = entry.getValue();System.out.println(key + "---" + value);}}}
- 不需要加泛型 , 工作中只存字符串
