public class ArrangeWordsAlphabetically {
/**
* @param StringToBeOrdered
* Splits keyword at white space and arranges them alphabetically
*/
public String orderAlphabetically(String StringToBeOrdered) {
String stbr = StringToBeOrdered.toLowerCase();
String orderedString = new String();
ArrayList
String [] tempStr =null;
tempStr = stbr.split("\\s+");
for (int i = 0 ; i <>length ; i++) {
pList.add(tempStr[i]);
}
// sort list
Collections.sort(pList);
// iterate through list
for (String str : pList)
orderedString +=str + " ";
System.out.println(orderedString);
return orderedString;
}
}
1 comment:
Nice brief and this enter helped me alot in my college assignement. Say thank you you seeking your information.
Post a Comment