top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

program to implement linkedlist using java

+3 votes
program to implement linkedlist using java
posted Sep 22, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Assuming that you want single linklist -

public class Node
    public Object data; //the data stored in this node
    public Node next; //store a reference to the next node in this singlylinkedlist
    public Node(Object data,Node next){ =data; =next;

public class SinglyLinkeList
    Node start;
    public SinnglyLinkedList()

    public void addFront(Object newData)
        Node cache = this.start; //store a reference to the current start node
        this.start = new Node(newData,cache); //assign our start to a new node that has newData and points to our old start
    public addRear(Object newData)
        Node cache = start; 
        Node current = null;

        while((current = != null) //find the last Node
            cache =; = new Node(newData,null); //create a new node that has newData and points to null

    public Object getFront()
        return; // return the front object's data
answer Sep 22, 2013 by Deepankar Dubey
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.