在Java中创建属性对象

在Java中创建属性对象,java,Java,如果我们创建一个属性,如: Properties properties = new Properties(); properties.put("[%1]", "username"); properties.put("[%2]", "password"); 然后在属性中添加什么作为键。从继承put方法,因此在您的情况下,您的键将是[%1]和[%2] 这就是你想知道的 Properties是Hashtable的子类,它表示一组持久的属性 Propertiesput方法是从超类哈希表继承的 对我来说

如果我们创建一个属性,如:

Properties properties = new Properties();
properties.put("[%1]", "username");
properties.put("[%2]", "password");
然后在属性中添加什么作为键。

从继承put方法,因此在您的情况下,您的键将是[%1]和[%2]

这就是你想知道的

Properties是Hashtable的子类,它表示一组持久的属性


Propertiesput方法是从超类哈希表继承的

对我来说,这就像一道考试题……在不打扰好人的情况下找出答案的步骤是:1文件->打开2复制粘贴3文件->保存4 javac。
public V put(K key,
    V value)
properties.put(<key>, <value>);