class Human{
String name;
String sex;
int age;
String add;
void work(){
System.out.println("i am working!");
}
void eat(){
System.out.println("i am eating!");
}
String getState(int time){
String state=null;
if(time>0 && time<24){
if(time>8 && time<17)
System.out.println("i am working");
else if(time>17 && time<22)
System.out.println("i am studying");
else if(time<8 || time>22)
System.out.println("i am sleeping");
}else
System.out.println("the time is wrong");
return state;
}
}
public class Day64 {
public static void main(String args[]){
Human mumu=new Human();
mumu.name="mumu";
mumu.sex="girl";
mumu.add="zhanjiang";
System.out.println(mumu.name+"what are u doing at 9 oclock?");
System.out.println(mumu.getState(9));
System.out.println("what about 23?");
System.out.println(mumu.getState(23));
}
}
请问为什么调用不了时间?得出来的结果是这个?
mumuwhat are u doing at 9 oclock?
the wrong time
what about 23?
the wrong time
------解决方案--------------------
神马玩意?
没见到哪儿打印 the wrong time 的。。。
------解决方案--------------------
state为啥没赋值????
------解决方案--------------------
运行没什么毛病呀,很正常呢
------解决方案--------------------
真不知道你的the wrong time哪来的。。