|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
(Optional) Converting a list-of-words to pig latin is now easy -- have a for-each loop which calls that function repeatedly.
But who has a list of words? We want to take in an entire sentence (one big String which includes spaces)! No problem -- it turns out, the String method split(" ")1 gives us back something which is usable with for-each. Try (in the Code Pad, using shift-enter for multiple lines):
for (String w : "It is a nice day, eh?".split(" ")) { System.out.println("w is " + w); } |
1Or, to handle punctuation, use split("[ .,;:!?]"). ↩
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2007, Ian Barland, Radford University Last modified 2007.Nov.26 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |