java类和对象的问题
publicclasstime1{privateinthour;privateintminute;privateintsecond;publictime1(){setti...
public class time1 {
private int hour;
private int minute;
private int second;
public time1()
{ settime(0,0,0);}
public time1(int hh)
{ settime(hh,0,0);}
public time1(int hh,int mm)
{ settime(hh,mm,0);}
public time1(int hh,int mm,int ss)
{ settime(hh,mm,ss);}
public void settime(int hh,int mm,int ss)
{
hour=((hh>=0&&hh<24)?hh:0);
minute=((mm>=0&&mm<60)?mm:0);
second=((ss>=0&&ss<60)?ss:0);
}
public String toString()
{
return (hour+":"+(minute<10?"0":"")+minute+":"+(second<10?"0":"")+second);
}
}
上面的类中最后的成员方法public String toString()
{
return (hour+":"+(minute<10?"0":"")+minute+":"+(second<10?"0":"")+second);
}
什么意思,麻烦解释一下。 展开
private int hour;
private int minute;
private int second;
public time1()
{ settime(0,0,0);}
public time1(int hh)
{ settime(hh,0,0);}
public time1(int hh,int mm)
{ settime(hh,mm,0);}
public time1(int hh,int mm,int ss)
{ settime(hh,mm,ss);}
public void settime(int hh,int mm,int ss)
{
hour=((hh>=0&&hh<24)?hh:0);
minute=((mm>=0&&mm<60)?mm:0);
second=((ss>=0&&ss<60)?ss:0);
}
public String toString()
{
return (hour+":"+(minute<10?"0":"")+minute+":"+(second<10?"0":"")+second);
}
}
上面的类中最后的成员方法public String toString()
{
return (hour+":"+(minute<10?"0":"")+minute+":"+(second<10?"0":"")+second);
}
什么意思,麻烦解释一下。 展开
7个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询