2016-06-08

How to Iterating all the Elements of a Linked List in java

/*
  Print elements of a linked list

  class Node {
     int data;
     Node next;
  }

 */
 
void Print(Node head) {
   while(head != null){
       System.out.println(head.data);
       head = head.next; 
   }
}

No comments:

Post a Comment