简体   繁体   中英

Doubly Circular Linked list GetData method

anyone can help me? y cannot get data result = temp.data below is my statement

public T getEntry(int givenPosition) {
    T result = null;
    if(root ==null)
        return null;
    else{
         DNode temp = root;

         for(int i=0;i<givenPosition;i++){
             //if(temp !=root.nextNode){
                 temp = temp.nextDNode;
                 //lala = temp.data;
             // }
         }
         result = temp.data;
    }
    return result;
}

public class DNode <T> {

    T data;
    DNode nextDNode;
    DNode previousDNode;

    DNode(T data){

        this.data = data;
        numberOfEntries++;

    }
}

尝试使用T进行make temp ,即DNode<T> temp = root;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM