下面的代码问题是因为把6、7行写反了,互换一下即可。
因为是要先把用用户需要打印的结果运行出来,然后再利用导入的scanner包,进行if判断。
1 import java.util.Scanner; 2 3 public class firstClass { 4 public static void main(String[] args) { 5 6 String Seat_Number = new Scanner(System.in).nextLine(); 7 System.out.println("请输入座位号"); 8 9 int AppointmentFailed = 111; 10 11 if(AppointmentFailed == 111) { 12 System.out.println("当前空闲"); 13 }else { 14 System.out.println("当前有预约"); 15 } 16 17 } 18 }标签:String,结果,System,代码运行,空白,AppointmentFailed,println,public,out From: https://www.cnblogs.com/wjdzh/p/18091002