不会报错。如果map是空的,flatMap(map -> map.values().stream())会返回一个空的Stream,不会有任何元素被处理。然后,flatMap(List::stream)会继续返回一个空的Stream,最后collect(Collectors.toList())会返回一个空的List<String>。

ListString result = liststream flatMapmap - mapvaluesstream flatMapListstream collectCollectorstoList;这样写如果map是空的会报错吗

原文地址: https://www.cveoy.top/t/topic/ilJN 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录