日期:2014-05-20 浏览次数:20742 次
package cn.puruidong.Test; /** * @author puruidong * */ import java.util.*; /* * 测试java常量 */ public class Toptest { /** * @param args */ private char sex; //记录性别 private String chooseto ;//记录判断 private static final int num = 10 ; //定义人数,整个所调用的num的值都为10 Scanner sc = new Scanner (System.in); public void show (){ boolean choose = true ; do { System.out.println("输入你的性别:"); sex = sc.next().charAt(0); switch (sex){ case '男': System.out.println("请进入1频道"); System.out.println("该频道最大人数:"+(num)); break; case '女': System.out.println("请进入2频道"); System.out.println("该频道最大人数:"+(num)); break; default: System.out.println("无此性别?"); break; } System.out.println("是否继续?(y/n)"); chooseto = sc.next(); }while (chooseto.equalsIgnoreCase("y")); } public static void main(String[] args) { // TODO Auto-generated method stub //num=20;提示“不能对终态字段进行赋值,而变量是二次赋值的,常量却不可以” Toptest center = new Toptest(); center.show(); } }