public class Test1{
public String sayHello(int hour) {
String msg;
if(hour >=8 && hour < 12) {
msg = “上午好”;
System.out.println(msg);}
else if(hour>=12 && hour <14){
msg = “中午好”;System.out.println(msg);}
else if(hour>=14 && hour <18) {
msg = “下午好”;System.out.println(msg);}
else {
msg = “晚上好”;
System.out.println(msg); }
return msg;
}
public static void main(String[] args) {
Test1 test1=new Test1();
test1.sayHello(12);
}
}