import java.util.Scanner;
public class Fernando {
public static void main(String[] args) {
Scanner skype = new Scanner(System.in);
System.out.print("What is your name ")?
String n = skype.nextLine(); // This is the line with the error
System.out.print("\n and how old are you?");
int y = skype.nextInt();
displayInfo(n,y);
}
public String displayInfo(String name, int age){
return name +" is "+ age+" years old.";
}
}
所有这一切都是预料之中的。我根本不明白什么是错的。
答案 0 :(得分:1)
尝试更改
System.out.print("What is your name ")?
为:
System.out.println("What is your name?");
这应该有效,因为你有?而不是;。