I need source code of "how to reverse a string in java without reversing the words(e.g. reverse it "Tech Support Problem" like "Problem Support Tech")". I know the procedure but cant write the code. So please send me the code.
Import java.util.*;
public class StringReverse {
public static void main(String[] argv) {
//+
String s = "Support Tech Problem";
// Put it in the stack frontwards
Stack myStack = new Stack();
StringTokenizer st = new StringTokenizer(s);
while (st.hasMoreTokens()) myStack.push(st.nextElement());
// Print the stack backwards
System.out.print('"' + s + '"' + " backwards by word is:\n\t\"");
while (!myStack.empty()) {
System.out.print(myStack.pop());
System.out.print(' ');
}
System.out.println('"');
//-
}
}
232 views
Usually answered in minutes!
×