单链表反转(非递归java实现)

来源:互联网 发布:php搭建网页服务器 编辑:程序博客网 时间:2024/05/16 06:26

java代码:

class NodeList{    public int value;    public NodeList next;    public NodeList(int data){        this.value = data;        }}NodeList reverseNodelist(Node head){        NodeList pre = null;        NodeList nextNode = null;        while(head!=null){                nextNode = head.next;                head.next = pre;                pre = head;                head = nextNode;            }        return pre;}
1 0
原创粉丝点击