package shb.java.test;
/**
* switch支持字符串
* @Package:shb.java.test
* @Description:
* @author shaobn
* @Date 2015-9-9上午8:55:41
*/
public class test_3 {
public static void main(String[] args) {
System.out.println(testSwitchStr("jiangsu"));
System.out.println(testSwitchInt(2));
System.out.println(testSwitchChar('B'));
}
public static char testSwitchChar(char ch){
switch (ch) {
case 'A':
return 'A';
case 'B':
return 'B';
default:
return 'R';
} }
public static int testSwitchInt(int num){
switch (num) {
case 1:
return 1;
case 2:
return 2;
default:
return 0;
}
}
public static String testSwitchStr(String str){
switch (str) {
case "beijing":
return "hellobeijing";
case "jiangsu":
return "hellojiangsu";
default:
return "helloworld";
} }
}