如果您查看它所说的代码行
System.out.println("Please enter the firstname of your favourite female author");
mFirstName = scanner.nextLine();
System.out.println("Please enter her second name");
mSurname = scanner.nextLine();
它完全跳过了名字部分并直接进入姓氏?任何想法为什么会发生这种情况?
import java.util.*;
'class university{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
Person2 mPerson, fPerson;
String fFirstName, fSurname, mFirstName, mSurname;
int fAge, mAge;
System.out.println("Please enter the firstname of your favourite female author");
fFirstName = scanner.nextLine();
System.out.println("Please enter her second name");
fSurname = scanner.nextLine();
System.out.println("Please enter her age");
fAge = scanner.nextInt();
System.out.println("Please enter the firstname of your favourite female author");
mFirstName = scanner.nextLine();
System.out.println("Please enter her second name");
mSurname = scanner.nextLine();
System.out.println("Please enter her age");
mAge = scanner.nextInt();
System.out.print(fPerson);
}
}