-2
当我运行程序时,它提示我 “请输入包含女孩名字的文件名。” Then “请输入包含男孩名字的文件名称。” 并没有什么事情发生,但代码不会终止为什么我的代码不能继续?
public static int getBoys(ArrayList<String> boysNames, Scanner s) throws IOException
{
//Getting boys file location
System.out.println("Please enter the file name containing the the boys names.");
String boyFileLocation=s.nextLine();
//Opening the file containing the names of boys
File boyFile = new File(boyFileLocation);
Scanner BF = new Scanner(boyFile);
int initialBoyCount=0;
while(BF.hasNext())
{
for (int i=0;i<boysNames.size();i++)
{
if(BF.nextLine()==boysNames.get(i))
{
}
else
{
boysNames.add(BF.nextLine());
}
}
}
return(initialBoyCount);
}
可能要添加到阅读'无限boysNames'。我认为你删除循环。 –
所以你甚至没有添加任何调试来试图找出它自己? – John3136
显示的代码中没有任何内容显示打印输入女孩消息或处理女孩输入的位置。 – pczeus