小编coo*_*tah的帖子

我试图将一个方法转发给super,但偶尔也不起作用.为什么?

这是有问题的代码,为此示例简化:

/** A version of Hashtable that lets you do
 * table.put("dog", "canine");, and then have
 * table.get("dogs") return "canine". **/
public class HashtableWithPlurals extends Hashtable {
  /** Make the table map both key and key + "s" to value. **/
  public Object put(Object key, Object value) {
    super.put(key + "s", value);
    return super.put(key, value);
  }
}
Run Code Online (Sandbox Code Playgroud)

java

4
推荐指数
1
解决办法
116
查看次数

为什么我的属性对象在我执行get时会忽略默认值?

Properties defaults = new Properties();
defaults.put("color", "black");

Properties props = new Properties(defaults);

// This prints "null, black"
System.out.println(props.get("color") + ", " + props.getProperty(color));
Run Code Online (Sandbox Code Playgroud)

java

1
推荐指数
1
解决办法
97
查看次数

标签 统计

java ×2