我试图在一行代码中打印出整个“f”变量.. f 显然代表女性,但是当我使用我的代码方式时它显示错误?
对不起,我是初学者。
import java.util.*;
class university {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
Person2 mPerson, fPerson = null;`
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();
scanner.nextLine();
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();
fPerson = new Person2(fFirstName, fSurname, fAge);
System.out.print(fPerson);
}
}