was wondering if someone could write an example code for elements of array being displayed in alphabetical order. The elements have come from the users input and have been stored in the array. Thanks.
1 Answer
A simple example
String[] strArray = {"Carol", "bob", "Alice"};
Arrays.sort(strArray, String.CASE_INSENSITIVE_ORDER);
System.out.println(Arrays.toString(strArray));
1 Comment
Patrick Parker
Note that this Comparator
String.CASE_INSENSITIVE_ORDER does not take locale into account, and will result in an unsatisfactory ordering for certain locales.
String[]?