Java has no pointer, but it can achieve the same effect as the pointer.
//// // Node // class Node {public Double X; public node next; Public node pre; node (Double X, node N) {This. X = x; this. pre = NULL; this. next = N;} node (Double X) {This. X = x;} public node getnext () {return next;} public void setnext (node next) {This. next = next;} public node getpre () {return pre;} public void setpre (node pre) {This. pre = pre;}/* Public node (Double X, node next) {This. X = x; this. next = Next ;} * //} // Linked List Implementation //////////////////// /// class list {public node head, tail; Public int length; List () {head = tail = NULL;} public Boolean isempty () // determines whether it is null {return head = NULL ;} public void addhead (Double X) // you can call {head = new node (x, null) once to add a head node. // PT. setnext (head. getnext (); // head. setnext (PT); If (tail = NULL) tail = head;} public void addtail (Double X) // Add nodes {If (! Isempty () {tail. next = new node (x); tail = tail. next;} else {head = tail = new node (x) ;}} public void print () {for (node temp = head; temp! = NULL; temp = temp. next) {system. out. print (temp. X + "");} system. out. println ("");} public void addnow (Double X, Double Y) // insert a node {for (node temp = head; temp! = NULL; temp = temp. next) {If (temp. X = x) {node now = temp. next; node Ne = new node (y); temp. next = ne; ne. next = now ;}}}} //////////////////////////////////////// // public class test {/*** @ Param ARGs */public static void main (string [] ARGs) {// todo auto-generated method stublist K = new list (); K. addtail (1); K. addtail (2); K. addtail (4); K. addtail (5); K. addnow (2, 3); // after 2, insert the node K as 3. print ();}}