Java进阶-回顾 Properties 类应该掌握什么

  1. 集合对象的创建
  2. 向集合中添加元素
  3. 从集合中取出某个元素
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.Properties;

public class PropertiesTest01 {

public static void main(String[] args) {
// 创建一个 Properties 对象
Properties pro = new Properties();

// 存
pro.setProperty("name", "wei");
pro.setProperty("password", "123");

// 取
String url = pro.getProperty("name");
String password = pro.getProperty("password");

System.out.println(url + "-->" + password);
}
}