Saturday, May 6, 2017

Linked List in Java

Here is a simple implementation of linked list data structure in Java. The code is very short and easy to understand.  Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Program Listing


package list;

import java.util.*;

public class linked_list {
   
public static void main(String args[]) {
LinkedList <String> users= new LinkedList <String>();

users.add("Samboy");
users.add("Allan");
users.add("Rudy");
users.add("Maria");
users.add("Robert");
users.add("Linda");

Iterator <String> list_all =users.iterator();
 
 System.out.println();
 System.out.println("List of Users");
 System.out.println();
 
 while(list_all.hasNext()){
  System.out.println(list_all.next());
 }

}
}

No comments:

Post a Comment