and output is:public class LinkedList { static Node start,end; public static void main(String... args) { toNode(args); } static void toNode(String... arr) { end=start=new Node(Integer.parseInt(arr[0])); Node p=start; for(int i=1;i<arr.length;i++) { p.next=new Node(Integer.parseInt(arr[i])); System.out.println(arr[i]+"inserted at "+p.next); } System.out.println("-------------------\nlocation of start: "+start); System.out.println("location of start.next: "+start.next); System.out.println("location of end: "+end+"\n\n"); //-------------------problem----------------------------- System.out.println("And output of traversing is: \n"); for (p = start; p != null; p = p.next) { System.out.println(p.data); } //--------------------------------------------------------- } } class Node { int data; Node next; Node(int data) { this.data=data; } }
45inserted at Node@3e25a5
78inserted at Node@19821f
23inserted at Node@addbf1
45inserted at Node@42e816
19inserted at Node@9304b1
24inserted at Node@190d11
687inserted at Node@a90653
47inserted at Node@de6ced
-------------------
location of start: Node@c17164
location of start.next: Node@de6ced
location of end: Node@c17164
And output of traversing is:
12
47
plz tell me why it is having only two node and it is not behaving like a LinkedList according to me there is no problem..................plz tell me