[Java] 12. Lambda Expression Basic

김미숙's avatar
Feb 26, 2025
[Java] 12. Lambda Expression Basic
‼️

행위 전달 표현식

  • Functional Interface
  • 함수형
  • 1. Consumer 2. Supplier 3. Predicate (true or false) 논리 4. Function 5. Callable
 
package ex07.ch02; // run 행위 전달 // 인터페이스로 정의 -> 행위는 한 개만 // 람다 식으로 행위 전달 interface Can1 { void run(); } public class Beh01 { // 행위를 전달 받을 ? 것 구현 static void start(Can1 can1) { can1.run(); } public static void main(String[] args) { // 람다 표현식: 내부적으로는 익명클래스 // 행위 전달 표현식 start(() -> { System.out.println("달리자1"); }); start(() -> { System.out.println("달리자2"); }); } }
Share article

parangdajavous