所以我试图从用户那里获取所有这些字符串输入。现在我遇到的问题是,当我选择案例2时,我得到这样的输出。为什么第一行和第二行都打印在一起。无法弄明白。提前谢谢。
输出
你选择了第2项
输入房屋的街道地址:
输入城镇名称
case 2:
System.out.println("You've chosen item #2");
System.out.println("Enter the Street Address of the house:");
String streetAddress = sc.nextLine();
System.out.println("Enter the name of the town");
String nameTown = sc.nextLine();
System.out.println("Enter the postcode of the town");
String townPostcode = sc.nextLine();
System.out.println("Enter the name of the landlord:");
String landLordname =sc.nextLine();
System.out.println("Enter the contact number of the landlord:");
String landlordContact = sc.nextLine();
System.out.println("Enter the name of the tenant if any or enter null");
String tenantName=sc.nextLine();
System.out.println("Enter the contact number of the tenant if any or enter null");
String tenantContact = sc.nextLine();
System.out.println("Enter the rent of the house if any or enter null");
String rent =sc.nextLine();
System.out.println("Enter the number of weeks in the lease contract or enter null");
int lease = sc.nextInt();`