@FunctionalInterface
-
람다 표현식(lambda Expression)JAVA/스트림, 컬렉션 프레임워크, 람다 2024. 6. 6. 17:22
▤ 목차">HTML 삽입미리보기할 수 없는 소스 ✔ 람다 표현식java SE 8부터 나온 람다 표현식은 메서드를 하나의 식으로 표현한 것을 말한다.하나의 추상 메서드를 가지고 있는 인터페이스를 가지고 있어야 사용이 가능하다.무명 클래스를 화살표 기호를 사용하여 짧게 줄일 수 있다.(parameter ,,,) -> { body }만약, 람다식이 하나의 메서드를 호출하는 경우 ::으로 표현할 수 있다.1) 클래스 이름 :: 메서드 이름2) 참조변수 :: 메서드 이름가독성이 좋은 쪽으로 선택하자.💻 코드로 보기interface HelloInter { int calcData(int a, int b);}public class MyLambda1 implements HelloInter { @Override ..