public class World {
public static void main(String[] args) {
int one = 20 ;
String str=(one%2==0)?"one是偶数":"one是奇数";
System.out.println(str);
}
}
public static void main(String[] args) {
int one = 20 ;
String str=(one%2==0)?"one是偶数":"one是奇数";
System.out.println(str);
}
}
2015-05-24
case '一':
case '三':
case '五':
System.out.println("吃包子");
break;
可以把功能相同的 case 语句合并起来
case '三':
case '五':
System.out.println("吃包子");
break;
可以把功能相同的 case 语句合并起来
2015-05-24
if(score>80){
if(sex.equals("女")){
System.out.println("进入女子组决赛");
}else{
System.out.println("进入男子组决赛");
}
}else{
System.out.println("你out了");
}
if(sex.equals("女")){
System.out.println("进入女子组决赛");
}else{
System.out.println("进入男子组决赛");
}
}else{
System.out.println("你out了");
}
2015-05-24
if(age>60){
System.out.println("老年");
}else if(age>=40){
System.out.println("中年");
}else if(age>18){
System.out.println("少年");
}else{
System.out.println("童年");
}
System.out.println("老年");
}else if(age>=40){
System.out.println("中年");
}else if(age>18){
System.out.println("少年");
}else{
System.out.println("童年");
}
2015-05-24
if(age>=18){
System.out.println("成年了");
}else{
System.out.println("未成年");
}
System.out.println("成年了");
}else{
System.out.println("未成年");
}
2015-05-24
System.out.println((!a)+"未通过");
System.out.println((a||b)+"通过");
System.out.println((c&&d)+"未通过");
System.out.println((d^a)+"通过");
System.out.println((a||b)+"通过");
System.out.println((c&&d)+"未通过");
System.out.println((d^a)+"通过");
2015-05-24
int one = 10 ;
int two = 20 ;
int three = 0 ;
int three1=0;
int three2=0;
three1=one+two;
System.out.println("three = one + two ==>"+three1);
three1+=one;
three2=three1;
System.out.println("three += one ==>"+three2);
int two = 20 ;
int three = 0 ;
int three1=0;
int three2=0;
three1=one+two;
System.out.println("three = one + two ==>"+three1);
three1+=one;
three2=three1;
System.out.println("three += one ==>"+three2);
2015-05-23
在二维数组赋值的时候要注意。public class HelloWorld { public static void main(String[] args) {String[][] names= {{"tom","jack","mike"}, {"zhangsan","lisi","wangwu"}};for (int i = 0; i < names.length ; i++) } for (int j = 0; j < names[i].length; j++) {System.out.println(names[i][j] )}System.out.println();}}}
2015-05-23