consumer

    [Java] 자바에서 제공하는 함수형 인터페이스

    Function T타입을 받아서 R타입을 리턴하는 함수형 인터페이스 함수 조합용 메소드 : andThen, compose [예제] compose는 (...)안의 람다식을 먼저 계산한다. andThen은 plus를 먼저 계산하고 (...)안의 람다식을 계산한다. Function plus = (num) -> num + 5; Function multiply = (num) -> num * 2; Function world = (s) -> s + " world"; System.out.println(plus.apply(5)); // 10 System.out.println(multiply.apply(5)); // 10 System.out.println(world.apply("hello")); // hello world..