function theHunt($node)
{
foreach ($node->children() as $child);
{
if (isset($child))
{ //has children
theHunt($child); //go one level down
}
else
{ //this is a child
//enum thru its attributes
}
}
}
当我运行我的代码时,我的第一个循环通过我的扫描仪,但后来我遇到了错误。我不确定自己做错了什么?我需要循环,直到10个问题得到正确回答,20个回答总体,或者正确答案的平均值超过85%。
What is the result?
10 - 7 =
3
Congratulations, you got it correct!
Exception in thread "main" What is the result?
9 + 8 =
java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at proj3.Project4App.main(Project4App.java:28)
}
答案 0 :(得分:0)
将Scanner scan = new Scanner(System.in);
带出您的周期。对scan.close;
执行相同的操作,在退出main
函数之前将其正确放置。当您close
Scanner
时,它也会关闭其来源。这可能是你例外的原因。