java Map上的java.util.NoSuchElementException

时间:2013-01-23 18:39:26

标签: java iterator

我只是想不通是什么问题,为什么这段代码抛出java.util.NoSuchElementException,因为在下一个方法之前有hasNext叫

        Map results = getResults();
        if (results != null) 
        {

            Set set = results.entrySet();
            Iterator it = set.iterator();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();
                Iterator jt = ((Collection) entry.getValue()).iterator();
                while (jt.hasNext()) {
                    CustomException e = (CustomException) jt.next();
                    String exp = e.getMessage();
                    exp = (exp == null)?"":exp;
                    if(!"".equals(exp) && !exp.contains("errors"))
                    {
                        setError(exp)
                    }


                }
            }
        }

0 个答案:

没有答案