Hi Experts,
Here is a simple sorting program of an ArrayList:
ArrayList<String> list = new ArrayList<String>();
list.add("1_Update");
list.add("11_Add");
list.add("12_Delete");
list.add("2_Create");
Collections.sort(list);
for (String str : list) {
System.out.println(str.toString());
}
I was expecting the output of this program as:
1_Update
2_Create
11_Add
12_Delete
But when I run this program I am getting output as:
11_Add
12_Delete
1_Update
2_Create
Why is this and how do I get the ArrayList to sort as shown in the expected output?