字符串: string(不是基础数据类型,应用数据类),字符串必须使用“ ”+ : 链接字符串,如果其他的数据类型+“ ”就变成了字符串
if:if多用于范围选择,switch多个单值匹配。java中的switch可以是整数、字符(java中char会自动转换了int)
if(2>1){
System.out.println("成立");
}else{
System.out.println("不成立");
}
switch:
int score = 'a';
switch(score){
case 'a':System.out.println("优秀");break;
case 'b':System.out.println("良好");break;
case 'c':System.out.println("及格");break;
case 'd':System.out.println("差生");break;
default:System.out.println("不清楚");
}
循环
while:
int i = 0;
while(i<100){
System.out.println("i:"+i);
i++;
do while
int j = 0;
do{
System.out.println("j:"+j);
j++;
}while(j<100);
while 和 do while的区别是,dowhile至少会执行一次
while和if的区别:结束的地方不一样,while条件结束,当满足条件执行完了后还需要进行一次条件判断就while
int a = 1;
int b = 2;
if(a<b){
System.out.println("a<b");
a=3;
}
int c = 1;
int d = 2;
while(c<d){
System.out.println("c<d");
c=3;
}
break 和 continue
for(){
for(int h=0;h<10;h++){
if(h==5){
//跳出本次循环
continue;
//break;//跳出本层循环
}
System.out.println(h);
}
}
for(;;){//是死循环
System.out.println("1111111");
}
}