Lambda Manual

Lambda Manual

Posted by Young on January 10, 2016

JDK8 Lambda Manual

flagmap的功能把多个list整合在一起进行流化


        List together = Stream.of(asList(1, 2), asList(3, 4, 5))
                .flatMap(numbers -> numbers.stream())
                .collect(toList());

        assertEquals(asList(1, 2, 3, 4, 5), together);
        
        
        
         // BEGIN strings_numbers_filter
                List beginningWithNumbers
                        = Stream.of("a", "1abc", "abc1")
                        .filter(value -> isDigit(value.charAt(0)))
                        .collect(toList());
        
                assertEquals(asList("1abc"), beginningWithNumbers);
                // END strings_numbers_filter
</code>
</pre>