以前我是用一个flag来标识是否跳出,现看到有下列的用法
out:for(SearchCompanySearchResultsType result : results){
IdentityInfoType[] reusultInfoTypes = result.getCompanyIdentity();
for(IdentityInfoType reusultInfoType : reusultInfoTypes){
if(tenantOwner.equals(reusultInfoType.getIdentityOwnerValue())){
hasMatchedTenantOwnerInWS = true;
log.info("Find matched TenantOwner in Web Service ... ");
break out;
}
}
}
本文介绍了一种在Java中使用标签来实现循环提前跳出的方法。通过示例代码展示了如何利用标签来控制循环流程,特别是在嵌套循环中寻找特定条件匹配时更为有效。
266

被折叠的 条评论
为什么被折叠?



