package kkk;


interface Readable1 {

public void read();

}


class OuterClass2 {

private String myName;


OuterClass2(String name) {

myName = name;

}


public Readable1 createLocalClassInst(final int instID) {

return new Readable1() {

public void read() {

System.out.println("Outer inst name: " + myName);

System.out.println("Local inst ID: " + instID);

}

};

}

}


class LocalParamAnonymous {

public static void main(String[] args) {

OuterClass2 out = new OuterClass2("My Outer Class");

Readable1 localInst1 = out.createLocalClassInst(111);

localInst1.read();

Readable1 localInst2 = out.createLocalClassInst(222);

localInst2.read();

}

}

블로그 이미지

왕왕왕왕

,