我有以下示例代码,包含3层嵌套的for循环。
for(Continent continent : continentList)
{
for(Country country : continent.getCountries())
{
for(City city : country.getCities())
{
//Do stuff with city objects
}
}
}
是否有任何方法可以使用Guava和迭代器模仿这个嵌套的for循环?我一直在努力寻找一个合适的例子,但没有太多运气,我想知道是否有人能够帮助我?我的同事提到了使用过滤器。
编辑:修复了示例代码中的微小错误