您的问题是next()不会读取回车,它会被您的next next()或nextLine()自动读取。一直使用nextLine()并将输入转换为整数:
public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); System.out.print("nEnter flight number: "); int flightNumber = Integer.valueOf(scanner.nextLine()); System.out.print("nEnter departing city: "); String departingCity = scanner.nextLine(); System.out.print("nEnter arrival city: "); String arrivalCity = scanner.nextLine();}


