标签:exti test 参数 str bsp cas string gen rate
import java.util.Scanner;
public class Test6 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input =new Scanner(System.in);
System.out.println("pleace input your sex:(1=man,2=women)");
String sex=input.next();
char ch=sex.charAt(0);
switch(ch){
case ‘a‘:
System.out.println("men");
break;
case ‘b‘:
System.out.println("women");
break;
default:
System.out.println("red women");
break;
}
}
}
------------------------------------------------------------------------------------------
import java.util.Scanner;
public class Test7 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("please chooice menu:(1=用户管理,2=单位档案,3=开户行,4=会计期间)");
int chooice = input.nextInt();
switch (chooice) {
case 1:
System.out.println("用户管理");
break;
case 2:
System.out.println("单位档案");
break;
case 3:
System.out.println("开户行");
break;
case 4:
System.out.println("会计期间");
break;
default:
System.out.println("input error!");
}
}
}
Java开发中经典的小实例-(swich(){case:参数break;default: break;})
标签:exti test 参数 str bsp cas string gen rate
原文地址:http://www.cnblogs.com/L-zhihua/p/5988497.html