Java Interface (3) - 함수형 인터페이스, 익명 클래스
추상메소드가 하나만 존재하는 인터페이스를 함수형 인터페이스 라고 한다. defualt method, static method 가 있어도 괜찮다. (default / static method는 추상 메소드가 아니다) 추상메소드가 하나만 존재할 때 @FunctionalInterface 어노테이션을 달아준다. FunctionalInterface에 있는 추상메소드를 함수 라고 부른다. //Main.java @FunctionalInterface public interface MyRunnable { void run(); } @FunctionalInterface public interface MyMap { void map(); default void sayHello() { System.out.println("Hell..
프로그래머스 백엔드 1기/Java
2021. 8. 8. 00:47