Java继承错误

Java继承错误,java,inheritance,abstract,extends,Java,Inheritance,Abstract,Extends,以下是我的例子: 在接口一节中,注意到实现接口的类必须实现接口的所有方法。但是,如果类被声明为抽象类,则可以定义一个不实现所有接口方法的类。比如说, abstract class X implements Y { // implements all but one method of Y } class XX extends X { // implements the remaining method in Y } 在这种情况下,类X必须是抽象的,因为它没有完全实现Y,但类XX实际上

以下是我的例子:

在接口一节中,注意到实现接口的类必须实现接口的所有方法。但是,如果类被声明为抽象类,则可以定义一个不实现所有接口方法的类。比如说,

abstract class X implements Y {
  // implements all but one method of Y
}

class XX extends X {
  // implements the remaining method in Y
}
在这种情况下,类X必须是抽象的,因为它没有完全实现Y,但类XX实际上实现了Y

这是我的密码:

public interface IRunnable {
public Object[] run(Graph<Object, ?> graph, HashMap<Object, Point> positions, int numIter);
public Object[] runSet(Graph<Object, ?> graph, HashMap<Object, Point> positions, int numIter, int [] itr);
public HashMap<Object, Point> runHelper(Graph<Object, ?> graph,HashMap<Object, Point> positions, int numIter);
public Force calculateForces(Graph<Object, ?> graph, HashMap<Object, Point> positions, Object mainVertex);

}

public abstract class Runnable implements IRunnable {
    public Object[] run(Graph<Object, ?> graph, HashMap<Object, Point> positions, int numIter){
           Object[] res = new Object[2];
           long startTime = System.currentTimeMillis();
           res[0] = runHelper(graph, new HashMap<Object, Point>(positions), numIter);
           long endTime = System.currentTimeMillis();
           res[1] = endTime - startTime;
           return res;
        }
        public Object[] runSet(Graph<Object, ?> graph, HashMap<Object, Point> positions, int numIter, int [] itr){
             System.out.println(itr.length);
             Object[] res = new Object[itr.length];
             for ( int i = 0; i < itr.length; i++){
                 res[i] = run(graph, new HashMap<Object, Point>(positions), itr[i]);
             }
             return res;
        }
        public HashMap<Object, Point> runHelper(Graph<Object, ?> graph,HashMap<Object, Point> positions, int numIter){
            Collection<Object> vertices = graph.getVertices();
            HashMap<Object, Force> forces = new HashMap<Object, Force>();
             for ( int i = 0; i < numIter; i++){
                 for ( Object vertex : vertices ){
                     forces.put(vertex, calculateForces(graph, positions, vertex));
                 }
                 for ( Object vertex : vertices ){

                    positions.put(vertex, ForceFunctions.calculateShift(positions.get(vertex), forces.get(vertex)));
                 }
             }
             return positions;
        }
}

public class Eades extends Runnable {



public static Force calculateForces(Graph<Object, ?> graph, HashMap<Object, Point> positions, Object mainVertex){
    ArrayList<Object> vertices = new ArrayList<Object>(graph.getVertices());
    Force totalForce = new Force(0,0);
    Force neighborForce = new Force(0,0);
    Object neighborVertex = null;

    for ( int i = 0; i < vertices.size(); i++){
        neighborForce = null;
        neighborVertex = vertices.get(i);
        if ( mainVertex != neighborVertex ){  
            if ( graph.getNeighbors(mainVertex).contains(neighborVertex) ){
                neighborForce = ForceFunctions.attractive(positions.get(mainVertex),positions.get(neighborVertex));
            }
            else
                neighborForce = ForceFunctions.repulsive(positions.get(mainVertex), positions.get(neighborVertex) );

            totalForce.add(neighborForce);
        }
    }
    return totalForce;
}
我做错了什么?

Java在
Java.lang
包中有一个接口,它与您的类冲突。编译器认为您希望在
Eades
声明中从该接口进行扩展


将您的类重命名为其他(
MyRunnable
或更有意义的东西),这将处理错误。

不,它在
java.lang
中有
Runnable
——这与“默认包”不同。@JonSkeet:Yep,编辑了我的答案。谢谢你指出这一点。
The type Runnable cannot be the superclass of Eades; a superclass must be a class