Java实现单链表的就地逆置算法
先上结果图
Node.java
/*
* 节点类的泛型定义
*/
public class Node<T> {
T data;
Node<T> next;
public Node(Node<T> n){
next = n;
}
public Node(T obj,Node<T> n){
data = obj;
next = n;
}
public T getData(){
return data;
}
public Node<T> getNext(){
return next;
}
}
LinkList.java
/*
* 定义单链表
*/
public class LinkList<T> {
private Node<T> head;
privat