Good afternoon,
Can someone confirm what was said at the bottom of this post java - iterate the linked list The post mentions that you can use the syntax for (char c: linkedlistofchars) and it will still be O (n). I would like to access a list that looks like this ...
abcdef
actually starts at the beginning of the linked list at each iteration of the for loop, like this ...
a ab abc abcde abcdef
forcing access time not to be O (n).
How exactly does it work? This makes sense with an array and array operators, but how does java syntax know how to iterate over a linked list using a foreach loop in java?
I thought the LinkedList data structure was just an extra library, not part of the main language syntax. (I really understand that the LinkedList class is standard in java)
I hope I have explained my concern in sufficient detail .... Thank you
source share