如何在Java中调试“错误:错误:java.util.NoSuchElementException”?

时间:2017-05-16 01:58:18

标签: java

代码:

int i = MobStackHandler.this.getInstance().getConfigHandler().getMobStackingRadius();
        List localList = MobStackHandler.this.mobList;
        Iterator localIterator2;
        for (Iterator localIterator1 = Bukkit.getServer().getWorlds().iterator(); localIterator1.hasNext(); localIterator2.hasNext())
        {
          World localWorld = (World)localIterator1.next();
          localIterator2 = localWorld.getLivingEntities().iterator();
          LivingEntity localLivingEntity = (LivingEntity)localIterator2.next();
          if ((localList.contains(localLivingEntity.getType())) && (localLivingEntity.isValid())) {
            for (Entity localEntity : localLivingEntity.getNearbyEntities(i, i, i)) {
              if (((localEntity instanceof LivingEntity)) && (localEntity.isValid()) && (localList.contains(localEntity.getType()))) {
                MobStackHandler.this.stackOne(localLivingEntity, (LivingEntity)localEntity, ChatColor.valueOf(MobStackHandler.this.getInstance().getConfigHandler().getMobStackColor()));
              }
            }
          }
        }
      }
    }.runTaskTimer(getInstance(), 40L, 40L);
  }

错误:在com.obvious.handlers.MobStackHandler $ 1.run(MobStackHandler.java:87)〜[?:?]

1 个答案:

答案 0 :(得分:0)

作为Oracle Doc

<强> NoSuchElementException异常:

由枚举的nextElement方法抛出,表示枚举中没有更多元素。

如果你想调试只调试你的迭代。