如何在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:
}