I am confused by the List interface.It is supposed to represent an ordered collection.But it looks like the collection is ordered only when it is created.If I use add()method on the list,the new element is appended to the end of the list.In that case,isn't the inherent ordering of the collection lost? I am sure I am missing something important here.Can anybody help? thanks kris
List is "ordered" in the sense that things in the list stay in the order in which you put them. So if I create a list and add three elements:
then the three elements will remain in that order:
will print out Hello There World This is in contrast to an unordered collection, such as a Hashtable, where there is no guarantee about the order of the elements when you retrieve them.