您的位置:首页 > 编程语言 > Java开发

java学习之匿名类(2)

2016-09-29 18:40 197 查看
实际上匿名类就是
</pre><pre name="code" class="java">interface a{
f();
}
new a(){
f(){
print('');
}
};
e.g.

interface Service{
void method1();
void method2();
}
interface ServiceFactory{
Service getService();
}
class Implementation1 implements ServiceFactory{
priviate Implementation1();
xxxx;
public static ServiceFactory f = new ServiceFactory(){
public Service getService(){
return new Implementation1();
}
};
}


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: