Skip to content

함수형 인터페이스 #11

Description

@sendkite

주제

함수형 인터페이스란?

선정 배경

함수형 인터페이스 정의 정리

  • 추상메서드가 1개인 인터페이스
  • @FunctionInterface
  • 자바에서 함수형 프로그래핑
    • First Class Object
    • 순수 함수
    • 고차 함수
    • 불변성

본론

  • 추상 메서드가 1개인 인터페이스
  • 다른 메서드가 있더라도 추상 메서드가 1개라면 함수형 인터페이스이다.
@FunctionalInterface
public interface RunSomething {
    void doIt(); // 앞에 abstract 키워드를 생략한 것
    
    static printName() {  // 앞에 Public 키워드를 생략한 것. 인터페이스 임에도 메서드 정의 할 수 있다.
        System.out.println("Hello!");
    }; 

    default void printAge() {  // 인터페이스 임에도 메서드 정의 할 수 있다.
        System.out.println("나이");
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions