I am new to Collections and I am sorry in advance for the trivial question but I have been pondering on a one sentence I have read in Java tutorial that
A List is an ordered Collection (sometimes called a sequence).
What I have understood from it is that as I put elements in a list, it does automatic ordering for me and since I ran a simple code, it proved I was wrong:
List <String> list = new ArrayList<String>();
list.add("Chris");
list.add("Brian");
list.add("Matt");
list.add("Greg");
for (Iterator<String> it = list.iterator();it.hasNext();) {
System.out.print(it.next()+"\n");
}
which resulted in this not being ordered in any way:
Chris
Brian
Matt
Greg
So my question is What is meant by "A list is an ordered collection" ?
Thanks