交换机语句中的对象

时间:2016-11-24 17:58:32

标签: java object if-statement switch-statement

如何在switch语句中使用对象? 我不得不在我的代码中使用对象。我需要知道如何比较对象,使用和if语句或switch语句。

    userInput = userLnr.readLine();

        if (userInput !=null) {
            clerk1.username = userInput;

            userInput = userLnr.readLine();
            clerk2.username = userInput;

            userInput = userLnr.readLine();
            clerk3.username = userInput;

            userInput = userLnr.readLine();
            clerk4.username = userInput;

            userInput = userLnr.readLine();
            clerk1.password = userInput;

            userInput = userLnr.readLine();
            clerk2.password = userInput;

            userInput = userLnr.readLine();
            clerk3.password = userInput;

            userInput = userLnr.readLine();
            clerk4.password = userInput;
        }

    System.out.println("Enter username: ");
    String inputUsername = Keyboard.readString();

    System.out.println("Enter password: ");
    String inputPassword = Keyboard.readString();

    switch(inputUsername){
        case clerk1.username:
    }

0 个答案:

没有答案