Linked List in Java

linked list in javaIn 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.

If you like videos like this, it helps to tell Google+ [googleplusone]

Code From the Video

Link.java

LinkList.java

30 thoughts on “Linked List in Java”

  1. Hi darek nice video as always.
    also i am curious to know, if you have any idea about how to generate 3d data for performance testing, any tool for that, or how to automate it?

    Thanks,
    Punit

  2. Okay more precisely, so far we are creating data (2d data), using xml’s and loading that to our product and testing our application.
    now we need for 3d data to test our application, so is there any way to create 3d data?

  3. I was doing a program in the roman numeral using RomanNumeralGUI,RomanNumeralList, RomanNumeralLinkList and RNLinkListIterator. when I built the frame of RomanNumeral and I entered JMenu , it suppose to enter the roman numeral sorted and Unsorted and when I press add ‘M’ for example it should enter it and when i press “delete” it should delete . so my question is to delete the roman numeral….

  4. Great tutorials, thanks. Anyway there is a small typo:

    while(theLink.bookName != bookName){

    should be

    while(!theLink.bookName.equals(bookName)){

  5. I’m getting a sort of error. The program is printing the references for theLink.next, instead of the book name. I bypassed this problem by taking your toString() method from Link() and using it inside of LinkList.display() inside of the while loop.

    However, I’m curious as to how I can fix this problem otherwise. Everything else worked fine, except for when I was initially making use of the LinkList.display().

    When the program printed “Next Link: <expected book name" I got a reference/object instead, not the object's string contents. What should I be looking at to solve this?

  6. Good lord this is amazing!
    Thank you so much!
    I wish there were more people like you out there that can I actually teach!

  7. Awesome tutorial Derek, as always you are!
    I’m having a hard time to understand the difference between newlink.next & newlink….still confused
    newLink.next = firstLink;
    firstLink = newLink; which one is the address?

    1. Thank you 🙂 Each node (link) has a reference to the next node (link) in the chain. When I make the first node here is no other nodes so next gets the value of null.

      When I do add a new node I assign it to the the last node that was created. I put a reference to it in next.

      Think of it as a bunch of boxes. In each box there is a piece of paper that tells you what box to open up next. If you decide you want to add on a new box just right that boxes name on a piece of paper and stick it in the box that proceeds it.

      I hope that helps
      Derek

  8. Hi Derek, I watched your video tutorial, and I am very new to Java..
    I am having difficultties on how will I Integrate Scanner in Linkedlist “where user can input , say or example the bookname”. I have tried all the possible things that I could try, but still having trouble.

    I hope you’ll be able to help me with this..

    Thanks

  9. hi Derek , i am new for java code and I have straggle in Multi-Linked Lists. if you know any books to reference or if you make video .

  10. Hi Derek,

    Thanks for the video, it’s very helpful!!!
    I’m new to Java, Can you tell me how can I compile those two files by using “package”, or is there another way of compiling those two files? Thanks!!

Leave a Reply

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