I am working on a problem. I am almost done but the very last of my code is confusing me. I knew that Collections.sort() sorts word alphabetical order. But this code is not. In the java api it says: Sorts the specified list in to ascending order. Please correct me or provide some info.Here is the code:
import java.util.*;
class Ideone
{
public static void main (String[] args)
{
List <String> list = new ArrayList();
list.add("derail");list.add("Disk");list.add("advocate");list.add("ladder");
list.add("soon");list.add("eye");list.add("NotE");list.add("Bobycott");
Collections.sort(list);
for (String ananagram : list) {
System.out.print(ananagram+" ");
}
}
}
output is :
Bobycott Disk NotE advocate derail eye ladder soon
But I was Expecting:
advocate Bobycott eye derail Disk ladder NotE soon