linked list - What happens when iterating over a Java LinkedList using the native foreach syntax? -
i'm trying understand basic behavior of linked list when iterating on using foreach syntax. let's linkedlist contains a, c, b, d added in order, order should -> a-c-b-d. if iterate on linkedlist using foreach (which uses iterator implicitly udnerstand it), contract guarantee items retrieved in order? api doesn't seem this, though maybe it's obvious mention? i'm looking @ java 7 api: https://docs.oracle.com/javase/7/docs/api/java/util/linkedlist.html api mentions iterator fail-fast, , goes lot of detail that, says nothing can see iterator guaranteeing order of linked list.
the api doesn't seem this
oh yes does. "returns iterator on elements in list (in proper sequence)."
Comments
Post a Comment