package com.xxcsh.www.struct;publicclassswitchdeemo1{publicstaticvoidmain(String[] args){//case穿透
String name ="xxcsh";switch(name){case"xxcsh":
System.out.println("xxcsh");break;case"中华":
System.out.println("中华");break;default:
System.out.println("输入有误!");}}}
while循环
package com.xxcsh.www.struct;publicclasswhiledemo1{publicstaticvoidmain(String[] args){//计算1~100int i =0;int sum =0;while(i<=100){
sum = sum + i;
i++;}
System.out.println(sum);}}
package com.xxcsh.www.struct;publicclasswhiledemo2{publicstaticvoidmain(String[] args){//1000以内能被五整除的数,每三个换一行int i =0;while(i<=1000){if(i%5==0){
System.out.print(i+"\t");}if(i%(5*3)==0){
System.out.print("\n");}
i++;}
System.out.println(i);}}
for循环
package com.xxcsh.www.struct;publicclassfordemo1{publicstaticvoidmain(String[] args){//1000以内能被五整除的数,每三个换一行for(int i =0; i <=1000; i++){if(i%5==0){
System.out.print(i+"\t");}if(i%(5*3)==0){
System.out.println();}}}}