Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

인터페이스의 여러 추상 메서드는 함수인가. #4

Open
hamhyeongju opened this issue Feb 13, 2024 · 1 comment
Open

인터페이스의 여러 추상 메서드는 함수인가. #4

hamhyeongju opened this issue Feb 13, 2024 · 1 comment
Labels
question Further information is requested

Comments

@hamhyeongju
Copy link
Contributor

질문 내용

책에서 메서드를 파라미터로 넘길 수 있으면/클래스에 종속되지 않으면 함수로 분류한다고 했는데, 여러 추상메서드를 가진 인터페이스를 익명클래스로 구현할 때 추상 메서드를 함수로 볼 수 있을까요

참고할 만한 자료(선택)

지피티가 람다로 넘어가면 클래스로 만들어서 넘기거나, 바이트코드로 동적으로 어떻게 한다고 합니다.

ETC

  • 기타 사항
@hamhyeongju hamhyeongju added the question Further information is requested label Feb 13, 2024
@kwiyoon
Copy link
Contributor

kwiyoon commented Feb 13, 2024

  • 참고 자료
    람다 표현식을 포함한 소스 코드를 컴파일 했을 때
    내부 클래스를 컴파일했을 때 생기는 클래스 파일이 생성되지 않음
    => 람다는 함수다!

결론
익명 클래스 : 객체
람다 : 함수

함수형 인터페이스를 익명 클래스처럼 구현해서 사용하면 객체가 되는거고, 그 안의 추상 메서드는 결국 메서드가 되는거지.
하지만 람다로 사용하여 함수처럼 사용할 수 있는데 굳이 익명 클래스를 사용할 필요가 없다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants