As we all know there are many different ways of doing it with for loop, while loop, StringToeknizer or
public String ReverseStringWords(String StringToBeReversed) {
String reversedString = new String();
Stack stack = new Stack();
String [] tempStr =null;
tempStr = StringToBeReversed.split("\\s+");
for (int i = 0 ; i <>length ; i++) {
stack.push(tempStr[i]);
}
while(!stack.empty()) {
reversedString += (String) stack.pop() + " ";
}
return reversedString.toLowerCase();
}
}
No comments:
Post a Comment