class trylinklist11 { public static void main(String [] args){ // creating my list // starting by empty list list_node mylist=null; // temp node to run while creating the nodes list_node tmp=null; // creating first node mylist= new list_node(1); tmp=mylist; // creating second node and attach it to the list list_node N2= new list_node(2); tmp.link=N2; tmp=tmp.link; // creating third node and attach it to the list list_node N3= new list_node(3); tmp.link=N3; // to print the list if(mylist!=null){ tmp=mylist; // point to the first node System.out.println(tmp.data); tmp=tmp.link; // move to the next System.out.println(tmp.data); tmp=tmp.link; // move to the next System.out.println(tmp.data); } } }