import java.util.Collection; import java.util.HashSet; public class CollectionStream { public static void main(String[] args) { Collection books = new HashSet(); books.add("java"); books.add("疯狂"); books.add("C"); System.out.println(books.stream().filter(ele->((String)ele).contains("疯狂")).count()); System.out.println(books.stream().filter(ele->((String)ele).length()>1).count()); books.stream().mapToInt(ele->((String)ele).length()).forEach(System.out::println); } }