package cm.com.datastructure.linkedlist;
/**
* 实现单链表 翻转
*
* @author MemorysLiu
* @version 1.0.0
* @date 2019-07-31 15:14
*/
public class SinglyLinkedList {
public static void main(String[] args) {
Node node1 = new Node("1");
Node node2 = new Node("2");
Node node3 = new Node("3");
Node node4 = new Node("4");
Node node5 = new Node("5");
node1.next = node2;
node2.next = node3;
node3.next = node4;
node4.next = node5;
Node node = null;
Node current = node1;
while (current != null){
if (node == null){
node = current;
current = current.next;
node.next = null;
}else {
Node temp = current;
current = current.next;
temp.next = node;
node = temp;
}
}
System.out.println(11);
}
private static class Node{
String value;
Node next;
Node(String value){
this.value = value;
}
}
}