stream获取List最后一个元素

在这里插入图片描述

List<String> names = new ArrayList<>();
httpIds.sort(Integer::compareTo);

 httpIds.forEach(id -> names.add(Arrays.asList(marketCache.getHttpById(id).getHttpUrl().split("/")).stream().reduce((first, second) -> second).orElse("no last element")+"-"+marketCache.getHttpById(id).getDescription()));
return String.join(";", names);插入代码片

版权声明:本文为kook_k原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。