How to create customized singly linked list

Linked list work on the concept of FIFO – First in First out. i.e the element inserted first will be the one retrieved first.

Create a class which will act as data structure and act as a single Node.

 public class MyList {


            public Object ob;

            public MyList next;


            public MyList(Object ob){




Now create a class to implement the basic functionality:

public class MyLinkedList {


            private MyList first=null;

            private MyList last=null;


            public MyLinkedList (){



            public void add(Object o){

                        if(first == null){

                                    first = last= new MyList(o);


                           = new MyList(o);




            private void getData(){

                        MyList temp =first;


                                    System.out.println(temp.ob + ” “);


                        }while(temp != null);



            private void delete(Object o){

                        MyList temp =first;

                        MyList prev =null;







                                    prev = temp;


                        }while(temp != null);




public static void main(String args[]){

                         MyLinkedList lst = new MyLinkedList();







                         System.out.println(“After Insert”);



                         System.out.println(“After Delete”);





The output will be :

After Insert

6 62 16 65 26 25


After Delete

6 62 65 26 25



3 thoughts on “How to create customized singly linked list

  1. I must tell you that it’s hard to find your articles in google, i found this one on 22
    spot, you should build some quality backlinks in order to
    rank your webiste, i know how to help you,
    just type in google – k2 seo tips

  2. I read a lot of interesting content here. Probably you spend a
    lot of time writing, i know how to save you a lot of time, there is
    an online tool that creates unique, SEO friendly posts in minutes, just type in google – laranitas free content source

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s