您的位置:首页 > 编程语言 > Java开发

Java单链表基本操作(六)--删除重复节点;

2016-04-01 12:01 585 查看
package listnode;

public class DeleteDuplecate_SingleList {
public static void main(String[] args) {
Node head=ListNode.getSingleList();
ListNode.printList(head);
deleteNode(head);
ListNode.printList(head);
}

public static void deleteNode(Node head){
while(head.next!=null){
Node p=head;
while(p.next!=null){
if(p.next.data==head.data){
p.next=p.next.next;
}
p=p.next;
}
head=head.next;
}
}
}


代码中调用的Node类和ListNode类,代码详见

Java单链表基本操作(一)–顺序查找
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: