java中实现接口的方式有:1.使用implements关键字实现;2.使用匿名内部类实现;3.使用interface实现;
java中实现接口的方式有以下几种
1.使用implements关键字实现
public interface Com{}
public class Object implements Com{}
Com com = new Object();
2.使用匿名内部类实现
Thread thread=new Thread(new Runnable() {
public void run() {
}
});
3.使用interface实现
public interface IStudent {
final int X = 10;
float getScore(int studentNo);
int getStudentAge(int StudentNo);
}
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:java接口实现方式有哪些