I am confused about the LinkedList. They do not really make sense to me. Could someone explain to me how it basically works. For example I saw this code (below) and it did not make sense to me. From what I’m guessing a string list (list1) is created and is put in a LinkedList. But what is diffrence between list and LinkedList ?? Thanks
List<String>list1 = new LinkedList<String>()
LinkedList is a class implementing the List interface. A interface is not a actual class, its more like a convention/blueprint of what methods that classes implementing them needs to expose.
For example, if you have interface called Shape
notice that this contain a method body for draw, rather, its a convention saying all classes which implents this interface must have a method called draw. Now, lets say you have two classes which both implements the above interface
You can then cast instances of either Circle or Box into a Shape variable, and safely call the draw method.