java8新特性anymatch

public class test2 {

public static void main(String args[]) {

String ids=”1,2,3,4,5″;

List<Object> listIds = Arrays.asList(ids.split(“,”)).stream().collect(Collectors.toList());  

boolean result = listIds.stream().anyMatch(p->p.equals(“2”));

System.out.println(Arrays.toString(listIds .toArray()));//[1,2,3,3,4,5,6]  

System.out.println(result);

}

}

    原文作者:yzy_
    原文地址: https://blog.csdn.net/tongzuo244/article/details/80601951
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞