No value present 解决办法
接口报错:“No value present
No value present 问题解决.
stream findfirst() get()方法报错
我自己的业务代码
Optional<Store> business = Storelist.stream().filter(v -> v.getStoreId().equals(s.getStoreId())).findFirst();
Store nowbusiness = new Store();
if (business.isPresent()){
nowbusiness = business.get();
}
stackoverflow 的解决办法
Stream<T> stream = stream();
Optional<T> result = stream.filter(t -> {
double x = getX(t);
double y = getY(t);
return (x == tx && y == ty);
}).findFirst();
if (result.isPresent())
return result.get();
return null;
java8 stream findfirst().get()空指针