java编程问题:如何使用构造的方法进行初始化?

我定义了4个变量一个整型,两个字符串型,一个日期行,导入了java.util.date;
如何用构造的方法进行初始化?

private String key;

private String value;

KeyValueBean() {
}
KeyValueBean (String key,String value) {
this.key = key;
this.value = value;
}

public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}

public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-11-05
初始化需要变量,你定义一个就好了,在构造方法中应该可以定义的
我好久没看书了,都忘记了
相似回答