关于getter method和setter method的问题
什么情况下用getter method,什么情况下用setter method的呢?
他们的意思是什么?
例如:
public void setMonth(String M_onth){
month = M_onth;
}
把设置M_onth存储到month里,不知道我理解的对不对。
而
public String getMonth(){
return month;
}
是把算出结果返回到month值里
我总是有些糊涂,希望谁可以给我结解释详细一些?
另外,什么时候可以Constructor Method,什么时候不用?
谢谢