How can I seperate words in a sentence and I want it by using for or while statements and with using which methods, I don't know exactly. For example, our string is "one two three four"
. I want it sorted as an output like below;
one
two
three
four
How can I seperate words in a sentence and I want it by using for or while statements and with using which methods, I don't know exactly. For example, our string is "one two three four"
. I want it sorted as an output like below;
one
two
three
four
String newStr = oldStr.replaceAll(" ", "\n");
System.out.println(newStr);
Here is a point to start:
String text = "one two three four";
String[] words = text.split(" ");
// Now implement any sorting algorithm on the array "words"
and- tags can be sorted in whatever order you like via javascript. unordered list in html terms is referring to the styling not the actual sorting.
– Brian Jan 04 '12 at 22:57