/**
* switch的用法
* @author 够潮
*
*/
public class Demo4 {
/**
* @param args
*/
public static void main(String[] args) {
int a = 1;
//byte a = 1;
//char a = 1;
//long a = 1;
//String a = "";
String b = "";
b.length();//String有length方法,数组则只有length属性
String c[] = new String[10];
//int d = c.length;
switch(a){//switch中的参数类型只能是byte char long中的某一种类型
case 1:{
System.out.println(1);
break;//使用break跳出switch,否则程序会继续往下执行
}
case 2:{
System.out.println(2);
break;
}
default:System.out.println("找不到匹配");
}
}
}