함수형 인터페이스
함수형 인터페이스 - 제네릭
public class GenericMain1 {
public static void main(String[] args) {
StringFunction upperCase = s -> s.toUpperCase();
String result1 = upperCase.apply("hello");
System.out.println("result1 = " + result1);
NumberFunction square = n -> n * n;
Integer result2 = square.apply(3);
System.out.println("result2 = " + result2);
}
@FunctionalInterface
interface StringFunction {
String apply(String s);
}
@FunctionalInterface
interface NumberFunction {
Integer apply(Integer i);
}
}람다와 타겟 타입
자바가 제공하는 함수형 인터페이스
기본 함수형 인터페이스
Runnable
특화 함수형 인터페이스
기본형 지원 함수형 인터페이스
Last updated