Sorting Sentences

Write a program that creates an ArrayList of Strings. Let the user type in a sentence using keyboard.nextLine(). Using String.split(), break up the sentence into an array of Strings and then put those Strings into an ArrayList. Also, force all the Strings to lowercase.

Then, using the String ArrayList sorting function you already wrote, put the words in alphabetical order and print them out again.

Sentence: How I want a drink alcoholic of course after the heavy lectures involving Quantum Mechanics
Sorted: [a, after, alcoholic, course, drink, heavy, how, i, involving, lectures, mechanics, of, quantum, the, want]

Also, discover the origin of the sentence above.




©2013 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License