11智能在线
新记
java 怎么对已经实例化好的对象进行接口实现了
如题所述
举报该文章
相关建议 2017-04-04
java 中接口是不能实例化的
比如List Set Map都是接口
使用时先实现
List<String> list = new ArrayList<>();
当然还有匿名内部类使用
比如Runnable
Runnable r = new Runnable() {
public void run() {
for (int i = 1; i <= 5; i++) {
System.out.print(i + " ");
}
}
};
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/vpfs87f8fqfp8mqv2p.html
其他看法
无其他回答
相似回答
大家正在搜