123456789101112131415161718192021222324252627282930313233343536 |
- package J20250728;
- import java.util.Properties;
- import java.util.Set;
- /**
- * @author WanJl
- * @version 1.0
- * @title Demo04_Properties
- * @description
- * @create 2025/7/28
- */
- public class Demo04_Properties {
- public static void main(String[] args) {
- //创建一个Properties集合对象
- Properties prop=new Properties();
- //存储元素---不需要使用了,有新的方法
- prop.put("name","张三");
- prop.put("age","25");
- prop.put("sex","男");
- prop.put("username","zhangsan");
- prop.put("password","123456");
- //遍历集合
- Set<Object> keySet = prop.keySet();
- for(Object key: keySet){
- Object value = prop.get(key);
- System.out.println(key+"->"+value);
- }
- }
- }
|