java构造方法调用问题
java新手,求大神看一下,小弟不明白public class Time
{
int hour, minute, second;
Time(){
}
public Time(long currentTime){
currentTime = System.currentTimeMillis();
}
Time(int hour, int minute, int second){
this.hour = hour;
this.minute = minute;
this.second = second;
}
void setTime(long elapseTime){
long currentTime = elapseTime;
}//这块怎么用?
public long getHour(){
long totalMilliseconds = System.currentTimeMillis();//如何调用上边Time(long currentTime)来实现这行代码
long currentHour = (((totalMilliseconds / 1000) / 60) / 60) % 24;
return currentHour;
}
public long getMinute(){
long totalMilliseconds = System.currentTimeMillis();//如何调用上边Time(long currentTime)
long currentMinute = ((totalMilliseconds / 1000) / 60) % 60;
return currentMinute;
}
public long getSecond(){
long totalMilliseconds = System.currentTimeMillis();//如何调用上边Time(long currentTime)
long currentSecond = (totalMilliseconds / 1000) % 60;
return currentSecond;
}
}
----------------解决方案--------------------------------------------------------
当一个人看不懂你描述的问题的时候,说明你的思路真的很糟糕,先打好基础
----------------解决方案--------------------------------------------------------
回复 2楼 love云彩
谢谢,我已经解决问题了,使用this()来调用同类中构造方法,是我标记打错了 ----------------解决方案--------------------------------------------------------