Linked List in Java

Get the Code:

In this video, I’ll cover how work with a linked list in java. I’ll show you how they work in 4 different ways.

We’ll cover how to create them, what a link is, how to add and delete links, how to search through them and a whole bunch more. The basics you need to understand at the end are that:

1. A Link is an Object
2. Each Link has a reference to another Link in the List
3. The LinkedList has only a reference to the last Link added to it.






27 responses to “Linked List in Java”

  1. Caltrix PvP Avatar

    confused… too many 'linked' words …theLink…newLink….Link… had to rewind a lot..

  2. Maryam Umm Isa Avatar

    Thank you so much for such easy explanation!

  3. Adarsh Pawar Avatar

    please make linked list in c++.

  4. Simon Liao Avatar

    Not enough Zelda.

  5. Evan DeBiasse Avatar

    Honest question. Isn't this the opposite of how most linked lists are implemented? With a "head node" being equivalent to your "first link" that first link wouldn't "move" so to speak. Then each previous node would simply point to the newest node. This is essentially putting the oldest data at the end of the list. LinkedList index 0 would be new information correct?

  6. Sarrah Wilson Avatar

    My professor is making it where we have to pull the data from Files. He's using buffered reader. Your tutorials make sense, but when he has us read files in it throws me off.


    You are a wonderful teacher ………
    Thank you for this kind of nice videos…………

  8. odysseyofnoises Avatar

    I just don't get this stuff. I think it might be time to change my major…

  9. Zeev Ma Avatar

    You have a voice of someone who lost his vocal chords and is speaking with that little device on the throat

  10. surma Avatar

    so confusing ….

  11. M Dar Avatar

    Derek thanks for all your help, Your tutorials are the best, rest youtube Java tutorials are only waste of time

  12. Prince Kumar Avatar

    Guys I see a lot of people complaining in the comments that he is going too fast and it is confusing. This is NOT a tutorial for completer beginners. I have already taken data structures in college and I am using this as a nice way to REVIEW. Emphasis on review. So I recommend that you take a course and read a data structure book intended for beginners. When you come back to review after a while, these videos will be perfect.

  13. RaitonGG Avatar

    why you building "to the left" though? can't you just keep first? and point it's next to the new added node, or link or whatever?

  14. Vinay KR Avatar

    You save a lot of our time by making those edits. Thanks for that. This also helps in not losing my focus

  15. Vinay KR Avatar

    Good video, Derek. But it beats me why you chose insert at first instead of insert at the end. You seem to have confused a lot of viewers 🙂

  16. Shakil Ahmed Avatar

    Hope it will help someone 🙂

    "if( == null) return theLink"
    Otherwise it will not find the first link from the list!

    public Link find( String bookName)
    Link theLink=firstLink;

    while(theLink.bookName != bookName)
    if( == null)
    return theLink;

    }else {;
    }else {
    System.out.println("The link was empty");

    return theLink;


  17. Irfan Sindhi Avatar

    Hey Derek, could you do a short tutorial on getters and setters?

  18. Ioannis Petridis Avatar

    Hello quick question !

    At 11:19 in "find" method why dont we use !theLink.bookName.equals(bookname) instead of theLink.bookName!=bookname ? Is there a specific reason ?

    Thank you !

  19. Joel Duran Avatar

    you analogy is a bit confusing but better than my professors explaining

  20. Spencer Davis Avatar

    hmmm, It seems that head is LinkedList or node on far left, and that is the first element created.
    Then the next element goes to the right of him. Then he has a reference to the next guy and so on.

    Since this is a singly Linked List, and pointing to the right, you can't have somebody to the right be moved in before somebody on the left.
    Anyway, this is how I understand it.

    Love your videos Derek you always have awesome code backing everything up —- just didn't understand the first part.

  21. Gavin Culmer Avatar

    I wish you were teaching Java on the course I'm doing

  22. Dez S Avatar

    Where is the head node? Does the head node contain any data aside from the reference to the first node?

  23. Brandon Edmonson Avatar

    Actually, each element of the LinkedList holds references "address" to both the element before it, and after it. This allows the 'hasNext()' and 'hasPrevious()' classes to work.

  24. Vandel Jason Strypper Avatar

    your example is too confusing

  25. Obi-Wan Kenobi Avatar

    Thank you. Thank you so much.

  26. Sanchit Jain Avatar

    Awesome videos Derek!
    i have a small doubt, please excuse my ignorance if the question is outrightly stupid.

    In the removeLink method in class LinkedList, after executing the line " =", even the firstLink changes. How does this work is what i am not able to get in my brain.

Leave a Reply

Your email address will not be published. Required fields are marked *