链表-返回链表长度

//返回链表长度
public int length(){
    int len=0;
    Node tmp=head;
    while(tmp!=null){
        len++;
        tmp=tmp.next;
    }
    return len;
}

猜你喜欢

转载自blog.csdn.net/weixin_42146769/article/details/88411104