Answer Posted / anjani kumar jha
import java.util.*;
public class StringReverseWord {
private static void doStringReverseWord() {
String a = "Anjani ...................Kumar Jha";
Stack stack = new Stack();
// this statement will break the string into the
words which are separated by space.
StringTokenizer tempStringTokenizer = new
StringTokenizer(a);
// push all the words to the stack one by one
while (tempStringTokenizer.hasMoreTokens()) {
stack.push(tempStringTokenizer.nextElement());
}
System.out.println("\nOriginal string: " + a);
System.out.print("Reverse string: ");
//pop the words from the stack
while(!stack.empty()) {
System.out.print(stack.pop());
System.out.print(" ");
}
System.out.println("\n");
}
public static void main(String[] args) {
doStringReverseWord();
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What data type is a string?
What is a type parameter in java?
what are the high-level thread states? : Java thread
Describe the various concepts related to object oriented programming (oop).
How do you identify if jvm is 32-bit or 64-bit from java program?
Is there any sort function in java?
What are the 6 mandatory procedures for iso 9001?
What is public static?
What is meant by bytecode?
Why is it called a string?
Which is easier .net or java?
What is boolean query?
what is bmg file and how to create that files?what will it contailn?
What is a parent class in java?
How does system arraycopy work in java?