当我运行此代码时,它只会打印listlist pre-requisite 1 pre-requisite 2
。它不允许用户输入prerequisite 1
并prerequisite 2
。请帮忙。
public static String Info(Scanner my)
{
System.out.println(“How many pre-requisites does the course
have”);
Int NumPreReq1= my.nextInt();
For ( i=1; i<=NumPreReq1; I++){
System.out.println(“list pre-requisite 1”);
String PreReq = my.nextLine();
}
Return PreReq;
}
答案 0 :(得分:0)
尝试my.next()
希望这会有所帮助......