调用 insteadList 反转数组
public Node<U> reverseList(Node<U> head) { if(head == null ) return null; Node<U> new_head = reverseList(head.next); if(new_head != null) { new_head.next = head; }else { this.first = head; } return head; } public void insteadList() { Node temp = first; //使不至于被销毁,反转后temp是最后一个 Node<U> uNode = reverseList(first); temp.next =null; //反转后temp是最后一个,它的next应为空,否则遍历懂的 temp = null; System.out.println("反转完成"); }