概念
1、各種Match作業可用來判斷給定的Predicate是否符合Stream的要素。
2、Match操作是終端機操作,傳回布林值。
實例
boolean anyStartsWithA =
stringCollection
.stream()
.anyMatch((s) -> s.startsWith("a"));
System.out.println(anyStartsWithA); // true
boolean allStartsWithA =
stringCollection
.stream()
.allMatch((s) -> s.startsWith("a"));
System.out.println(allStartsWithA); // false
boolean noneStartsWithZ =
stringCollection
.stream()
.noneMatch((s) -> s.startsWith("z"));
System.out.println(noneStartsWithZ); // true以上是java Match怎麼使用的詳細內容。更多資訊請關注PHP中文網其他相關文章!