java 怎么对已经实例化好的对象进行接口实现了

如题所述

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 + " ");
}
}
};
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜