LAMBDA1 [Java] 익명 클래스(Anonymous Class)와 람다식(Lambda Expression) 익명클래스(Anonymous Class) interface Printable { void print(); } class Printer implements Printable { public void print(String s) { System.out.println(s); } } class Example { public static void main(String[] args) { Printable prn = new Printer(); prn.print("hi"); } } 위 코드에서 Printer 클래스를 보자. Printer 클래스의 정의와 Printer 인스턴스의 생성이 분리되어 있다. 하지만 '익명 클래스'의 형태를 사용하면 클래스의 정의와 인스턴스 생성을 하나로 묶을 수 있다. class Exampl.. 2022. 9. 13. 이전 1 다음