出现此错误是因为您试图在接口 List 中实现方法。标记该接口没有方法体。如果要实现 size() 方法,则需要在 DSCircularList 类中实现它。
您需要实现 size 方法,例如:
在 Collection.java 文件中,
public interface Collection{
public int size();
}
在List接口中扩展Collection接口,List.java文件:
public interface List extends Collection{
//it extends size() method structure from Collection interface which needs to implement in any non abstract class.
//any extra method structures of List interface
}
在 DSCircularList 类,DSCircularList.java 文件中实现您的 List 类
public class DSCircularList implements List{
public static void main(String[] arg0){
}
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
}
所以,通过这个你可以制作你自己的 Collection 接口, List 接口并在你的代码中实现它。