char today='日';
switch(today){
case 1:
case 2:
case 3:
System.out.println("吃包子");
case 4:
case 5:
case 6:
System.out.println("吃油条");
default:
System.out.println("吃主席套餐");
}
switch(today){
case 1:
case 2:
case 3:
System.out.println("吃包子");
case 4:
case 5:
case 6:
System.out.println("吃油条");
default:
System.out.println("吃主席套餐");
}
2015-03-21
@淡描温情: 你的代码在在某些情况下会出现问题比如 刚好60时 会出现 输出是 童年 ,我优化后改进了一下 在楼下 。
2015-03-20
System.out.println(age >= 60 ? "老年" : age >= 40 && age < 60 ? "中年" : 18<= age || age<40 ? "少年" : "童年");
2015-03-20
int age=25;
if(age>60){
System.out.println("老年");
}else{if(age>40){
System.out.println("中年");
}else{lf(age>18){
System.out.println("少年");
}else{if(age<18){
System.out.println("童年");
}
}
if(age>60){
System.out.println("老年");
}else{if(age>40){
System.out.println("中年");
}else{lf(age>18){
System.out.println("少年");
}else{if(age<18){
System.out.println("童年");
}
}
2015-03-20
three=one+two;
System.out.println(three);
System.out.println(three+=one);
System.out.println(three-=one);
System.out.println(three*=one);
System.out.println(three/=one);
System.out.println(three%=one);
System.out.println(three);
System.out.println(three+=one);
System.out.println(three-=one);
System.out.println(three*=one);
System.out.println(three/=one);
System.out.println(three%=one);
2015-03-19
public class HelloWorld{
public static void main(String[] args) {
String city = "荆州";
System.out.println("我的家乡在:"+city);
}
}
public static void main(String[] args) {
String city = "荆州";
System.out.println("我的家乡在:"+city);
}
}
2015-03-19