[Solved] Java.util.NoSuchElementException: No value present

How can this error be reported?

Explanation: If you use re.get() to retrieve the value in the following code, you will get an error, and you need to use re.isPresent() before using it.

to determine whether the value can be retrieved. The above problem will not occur.

all.forEach(a->{
Optional<WetListVO> re = reWetL.stream().
filter(b->b.getDate().equals( a.getDate())).findFirst();
if(re.isPresent()){
a.setResidentWetCount(re.get().getResidentWetCount());
a.setResidentWetNum(re.get().getResidentWetNum());
}
Optional<WetListVO> bu = buWetL.stream().
filter(b->b.getDate().equals(a.getDate())).findFirst();
if(bu.isPresent()){
a.setResidentBucketCount(bu.get().getResidentBucketCount());
a.setResidentBucketNum(bu.get().getResidentBucketNum());
}

}

Similar Posts: