Java - 익명 클래스로 구현해보기

아래의 코드를 채워 익명 클래스로 구현하기.

Hello.Interface

interface Hello {
    void run();
}

Anonymous.class

class Anonymous {
    public static void main(String[] args) {
        // 익명클래스를 생성하고 hello() 호출하기
    }
}

Anonymous hello()


풀이

Anonymous.class

public class Anonymous {
    public static void main(String[] args) {
        Hello a = new Hello() {

            @Override
            public void run() {
                System.out.println("Anonymous Hello()");
            }
        };

        a.run();
    }
}