FileDocCategorySizeDatePackage
StringReverse.javaAPI DocExample670Sat Nov 25 12:56:18 GMT 2000None

StringReverse

public class StringReverse extends Object
Show String Reversals
version
$Id: StringReverse.java,v 1.4 2000/11/25 17:56:18 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

		//+
		String s = "Father Charles Goes Down And Ends Battle";

		// 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('"");
		//-