我希望在内部for循环中达到条件stop=true
时打破外部while循环。这可能吗?
urlsToScrape.addAll(startUrls);
boolean stop=false;
while(stop==false){
for(Link url:urlsToScrape){
p.rint(url.depth+" >= "+depth);
if(url.depth>=depth){
p.rint("STOP!");
stop=true;
break;
}
p.rint("scrape(): "+url.link+" / "+url.depth);
processLinks(url.link,url.depth);
urlsToScrape.remove(url);
scrapedUrls.add(url);
}
}
答案 0 :(得分:10)
使用标签:
outofthere:
while (stop==false){
for(Link url:urlsToScrape){
p.rint(url.depth+" >= "+depth);
if(url.depth>=depth){
p.rint("STOP!");
stop=true;
break outofthere;
}
p.rint("scrape(): "+url.link+" / "+url.depth);
processLinks(url.link,url.depth);
urlsToScrape.remove(url);
scrapedUrls.add(url);
}
}