我有以下 JAVA 代码。它编译得很好,但是当我运行它时,我得到了以下错误:
线程“main”中的异常 java.lang.NoSuchMethodError: Edge.(LVertex;D)V at Test.main(Test.java:27)
有什么线索吗?提前致谢!
import java.util.ArrayList;
class Vertex{
public int key;
public ArrayList<Edge> edges;
public double minDistance = Double.POSITIVE_INFINITY;
public Vertex(int key) {
this.key = key;
edges = new ArrayList<Edge>();
}
}
class Edge{
public Vertex target;
public double weight;
public Edge(Vertex t, double w) {
target = t;
weight = w;
}
}
public class Test {
public static void main(String[] args) {
Edge e = new Edge(new Vertex(1), 1.0);
}
}