在这种情况下如何使用界面

时间:2019-12-28 16:52:35

标签: class interface extend

public class Node<< K extends ObjectId, W extends Sum<W> & Comparable<W>>> {
public K key;
public ListItem<Edge<K, W>> headEdges;
public Node(K key) {
    this.key = key;
}
`Node class`
}

public interface ObjectId {

/**
 * @return ObjectId for this object
 */
public String getObjectId();

}

`interface ObjectId`
public class Graph<< K extends ObjectId, W extends Sum<W> & Comparable< W> > {
public ListItem<Node<K, W>> head;
public void connectNodes(String idFrom, String idTo, W weight) {
    Node<K, W> f = null;
    Node<K, W> t=null;
    for ( ListItem<Node<K, W>> p = head; p != null; p = p.next )
    {
    K s = p.key.key;
    if(s.getObjectId()==idFrom)
    f=p.key;}
}}

如果K等于idFrom,则在列表中搜索。

我不知道如何使用getObjectId()

0 个答案:

没有答案