public class Demo {
public static void main(String[] args) {
//构造一个properties集合
Properties pro = new Properties();
/*//添加集合元素
pro.put("t001", "张三");
pro.put("t002", "李四");
pro.put("t003", "王五");*/
pro.setProperty("t001", "张三");
pro.setProperty("t002", "李四");
pro.setProperty("t003", "王五");
/*//获取集合元素
Set<Object> stu = pro.keySet();
//遍历集合元素
for(Object obj:stu){
System.out.println(obj + "---" + pro.get(obj));//为什么一定要加分隔符才能编辑过去
}*/
//获取键集
Set<String> stu1 = pro.stringPropertyNames();
//遍历
for(String s :stu1){
System.out.println(s+pro.getProperty(s));//为毛不用加分隔符
}
}
}
|