java.util.NoSuchElementException 的问题
java.util.NoSuchElementExceptionatcom.google.common.collect.AbstractIterator.next(Abs...
java.util.NoSuchElementException
at com.google.common.collect.AbstractIterator.next(AbstractIterator.java:154)
at com.google.common.collect.Iterators.find(Iterators.java:712)
at com.google.common.collect.Iterables.find(Iterables.java:643)
at com.fulongkeji.huagang.service.impl.PointServiceImpl.getDPointBySendName(PointServiceImpl.java:35)
at com.fulongkeji.huagang.bean.CalculateEquipmentRuntimeJob.calcRuntime(CalculateEquipmentRuntimeJob.java:88)
at com.fulongkeji.huagang.bean.CalculateEquipmentRuntimeJob.executeInternal(CalculateEquipmentRuntimeJob.java:50)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:66)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
int newRuntime = 0;
try {
newRuntime = calcRuntime(mapping, calcFromTime(currentTime), currentTime);
}
catch (NoSuchElementException e) {
e.printStackTrace();--程序都会走这儿
continue;
}
if (newRuntime == 0)
continue; 展开
at com.google.common.collect.AbstractIterator.next(AbstractIterator.java:154)
at com.google.common.collect.Iterators.find(Iterators.java:712)
at com.google.common.collect.Iterables.find(Iterables.java:643)
at com.fulongkeji.huagang.service.impl.PointServiceImpl.getDPointBySendName(PointServiceImpl.java:35)
at com.fulongkeji.huagang.bean.CalculateEquipmentRuntimeJob.calcRuntime(CalculateEquipmentRuntimeJob.java:88)
at com.fulongkeji.huagang.bean.CalculateEquipmentRuntimeJob.executeInternal(CalculateEquipmentRuntimeJob.java:50)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:66)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
int newRuntime = 0;
try {
newRuntime = calcRuntime(mapping, calcFromTime(currentTime), currentTime);
}
catch (NoSuchElementException e) {
e.printStackTrace();--程序都会走这儿
continue;
}
if (newRuntime == 0)
continue; 展开
3个回答
展开全部
@GwtCompatible
public abstract class AbstractIterator<T> extends UnmodifiableIterator<T> {
// 下面是源码
@Override
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
state = State.NOT_READY;
T result = next;
next = null;
return result;
}
你都看到了。hasNext() 没有值呗。你看看你的集合呗。
追问
point= Iterables.find(allDPoints, new Predicate() { public boolean apply(DPoint point) {
if (sendName.equals(point.getPointSendName().trim()))return true else return false;
追答
return sendName.equals(point.getPointSendName().trim()) ;
还有
private static void test_afs() {
final String sendName = "asldjf";
List allDPoints = new ArrayList();
DPoint point = new DPoint();
point.setPointSendName("asldjf");
allDPoints.add(point);
try {
point = Iterables.find(allDPoints, new Predicate<DPoint>() {
public boolean apply(DPoint point) {
return sendName.equals(point.getPointSendName().trim());
}
});
System.out.println(point);
} catch (NoSuchElementException e) {
// 本身就没有你查的对象
}
}
如果你查询到了。就能显示。如果没有你查询到的对象。就抛出异常。所以首先你自己加上一个try/catch。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-03-27
展开全部
类里面,没有某个方法
PointServiceImpl.java:35
行
PointServiceImpl.java:35
行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
PointServiceImpl.java文件35行出错 可能是在这个类里面没有找到calcRuntime这个方法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询