As far as I know, the concept of a linked list is a bunch of object connected to each other by having a ‘next’ and sometimes ‘previous’ attribute to traverse the objects.
I noticed in Java, you can create a LinkedList object…but treat it like an array/list/sequence by using the same methods such as .add(), .get(), etc.
So, is LinkedList internally an array-like sequence?
No. It’s a series of instances of a private nested class
Entry, which hasnext,previousandelementreferences. Note that you could have found this out yourself by looking at the source code, which comes with the JDK.The reason why this internal structure is not exposed is that it prevents the structure from becoming corrupted and e.g. containing a loop. And the uniform access via the
ListandDequeinterfaces allows polymorphic use.