Practice Programs
Practice Programs can generally be solved with a short program that directly applies the programming principles presented in this chapter.
Revise the method
selectionSortwithin the classArraySorter, as shown in Listing 7.10 of Chapter 7, so that it sorts the strings in an instance of the classArrayList<String>into lexicographic order instead of sorting the integers in an array into ascending order. For words, lexicographic order reduces to alphabetic order if all the words are in either lowercase or uppercase letters. You can compare two strings to see which is lexicographically first by using theStringmethodcompareTo, as described in Figure 2.5 of Chapter 2.Repeat the previous practice program, but instead write a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access