【发布时间】:2010-10-27 13:57:58
【问题描述】:
我有一个这样的嵌套循环结构:
for (Type type : types) {
for (Type t : types2) {
if (some condition) {
// Do something and break...
break; // Breaks out of the inner loop
}
}
}
现在我怎样才能打破这两个循环?我看过类似的问题,但没有一个特别关注 Java。我无法应用这些解决方案,因为大多数使用 goto。
我不想将内部循环放在不同的方法中。
我不想返回循环。中断时,我完成了循环块的执行。
【问题讨论】:
标签: java loops nested-loops