日期:2014-05-20  浏览次数:20742 次

关于循环与再次循环的问题。
import java.util.Scanner;

public class  Test2
{
    public static void main(String[] args)
    {
            String username="admin";
            String password="admin";
            System.out.println("\t\t\t欢迎光临我的系统\n");
            System.out.println("\t\t\t\t1.登录系统\n");
            System.out.println("\t\t\t\t2.退出");
            System.out.println("*******************************************************************************************************************************************************\n");
                System.out.println("请选择,输入数字:");
                Scanner input=new Scanner(System.in);
                int num =input.nextInt();
                switch(num){
                case 1:
                        System.out.println("请输入用户名:");
                        String name=input.next();
                        System.out.println("请输入密码:");
                        String pass=input.next();
                        if(name.equals(username)&&pass.equals(password)){
                            System.out.println("进入系统");
                        }else{
                            System.out.println("输入有误,你无权进入系统,请重新输入数字");   
                            //?当执行到这边的时候想办法在让他重新在输入数字在执行
                        }
                        break;
                case 2:
                        System.out.println("谢谢你的使用。");
                        break;