public class whatTime {
public whatTime (int seconds){
String result = "";
int h = seconds / 3600;
int m = (seconds - h*3600)/60;
int s = seconds - h*3600 - m*60;
result = result + h + ":"+ m + ":" + s ;
}
public static void main ( String[] args) {
whatTime wTime = new whatTime(300);
System.out.println(wTime);
}
}
能说的具体点么
追答你的对象里面肯定有属性吧,其实你要显示的也就是这些属性,你应该是wTime.属性去显示,或者他们说的tostring在实体类中重写也可以,不能直接去打印对象,这样打印出来的是对象的地址
这个怎么能问问怎么重载么。。。
追答楼下已有人回答了