我陷入了 do-while 循环,需要循环 do-while 直到用户输入三个正确字符串之一
我试过这个
Scanner input = new Scanner(System.in);
String motor = "motor";
String mobil = "mobil";
String kosong = "";
String baru = "baru";
int tahun = Calendar.getInstance().get(Calendar.YEAR);
do {
inputVehicleType();
vehicleCondition = input.next();
}
while (!(vehicleCondition.equals(motor)) || (vehicleCondition.equals(mobil)) || (vehicleCondition.equals(kosong)));
System.out.println("SUCCED");
private static void inputVehicleType() {
System.out.println(Constant.HEADER);
System.out.println("Input Jenis Kendaraan Mobil/Motor --> (jenis [motor/mobil])");
titleFooter();
}
使用该语法,它只能检索 (vehicleCondition.equals(motor)。我的预期结果是它可以检索 (vehicleCondition.equals(motor), (vehicleCondition.equals(mobil), (vehicleCondition.equals(kosong)。
明月笑刀无情
萧十郎
收到一只叮咚
largeQ
当年话下
相关分类