기능적 프로그래밍 Java8 --- - 예

 

 

       // https://blog.csdn.net/weixin_41950473/article/details/84930562 (프레디 케이트, 스트림, 선택적 요소) - 기능적 프로그래밍 예제 Java8

//         집합 <정수> = nums 새로운 HashSet의 <> ();
//         대해 (INT 내가 = 0; I <100; 내가 ++) {
 //             정수 NUM = (INT) (100 * 인 Math.random ());
//             nums.add (NUM);
//             에서 System.out.println (num.intValue ());
//         }
 // 
//         // 술어语义
 //         술어 <정수> P1 = X -> x.intValue ()> 40 && x.intValue () <50;
//         술어 <정수> P2 = X -> x.intValue ()> 30 && x.intValue () <80;
// 
//         에서 <정수> = 입술 nums.stream () 필터 (p1.and (P2))를 수집 (Collectors.toList ())..;
//         은, Collections.sort (고해상도, Comparator.comparing (정수 ::있는 intValue)); // 排序, 비교기


        목록 <정수> = 입술 Arrays.asList (6,9,12 );

        // 옵션 
        목록 <정수> 값 =
            Optional.ofNullable (고해상도)
                    .MAP ((PARAM) -> {
                         반환 param.stream ()
                                .MAP (X - "X / 3 )
                                .collect (Collectors.toList ());
                    })
                    .orElseThrow (IllegalArgumentException가 :: );

        에서 System.out.println ( "--->"+ 값);

추천

출처www.cnblogs.com/hahajava/p/12074705.html