My guess is that they didn't really know what they were talking about, but that they probably meant the method Collections.sort(List).
I would say that a List is always ordered, period. A list always has an order, which behaves in a consistent, predictable manner. Whether it happens to be the same order as what you want it to be in, that's another question.
Perhaps they want a way to make sure it is sorted, as opposed to merely ordered? In that case, use Collections.sort(). Easy.
Note that Collections.sort() doesn't really maintain sort order. It just sorts the list, once. If you need something that maintains sort order continually, consider using a SortedSet, like TreeSet, rather than a List. Note that this is not possible if you need to be able to allow duplicates in the List. If that's a problem, consider Google Guava's TreeMultiset instead.
I wrote a simple program to check if the list always returns an ordered collection items. For me it does not seems working. I given the below program and output i got, can you tell me if i do something wrong here
But the output seems to be same like how the values were added to the list. It gets sorted only after using the Collections.sort(list). Kindly can you clarify if i do wrong here.
You didn't do anything wrong, I think you understood something wrong. We've been trying to tell you that any list is ordered. The problem is the definition of ordered. You're thinking that ordered means sorted, but in this context ordered means that the list has a specific order. That's not sorted order but insertion order. To make the list have a sorted order you need to manually keep it sorted; either by manually inserting elements at the right place, or by calling Collections.sort after each insertion.