• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

List interface

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also fee that this is probably more appropriate to the Java in General (Intermediate) forum, so I've moved it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic