我有一个这样的嵌套循环结构:
for (Type type : types) {
for (Type t : types2) {
if (some condition) {
// Do something and break...
break; // Breaks out of the inner loop
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我怎样才能摆脱两个循环?我看过类似的问题,但没有一个特别关注Java.我无法应用这些解决方案,因为大多数使用了gotos.
我不想把内循环放在不同的方法中.
我不想重新运行循环.当我完成循环块的执行时.