我想获取变量(gmtHourPrev)的先前值,所以我执行以下操作。出于测试目的更改时间后,我看到 gmtHourPrev 的值始终等于 gmtHour 并且无法获取它的先前值。我在这里做错了什么?谢谢
private int gmtHour;
private int gmtHourPrev;
public int getHour() {
return gmtHour;
}
public void setGmtHour(int gHour) {
this.gmtHourPrev = this.gmtHour;
this.gmtHour = gHour;
}
public int getGmtHourPrev() {
return gmtHourPrev;
}
public String getGmtHourInfo() {
gmtHour = Calendar.HOUR;
setGmtHour(gmtHour);
if (isOK() == true) {
return gmtHour;
}
else {
return getGmtHourPrev();
}
}