write a program, when a statement is entered, it should
display in reverse order.
Ex: Statement is "I am writing program in reverse order".
Output should be like "order reverse in program writing am I".
Answer Posted / abhinaw kumar
package com.test;
public class ReverseString {
public static String reverse(String sentence){
String[] temp=sentence.split(" ");
StringBuffer sb = new StringBuffer();
for(int i=temp.length-1;i>=0;i--){
sb.append(temp[i]+" ");
}
sentence = sb.toString();
return sentence;
}
public static void main(String[] args) {
String sentence="I am writing program in reverse order";
String revString = reverse(sentence);
System.out.println(revString);
}
}
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What does application client module contain?
What is bean factory, have you used xmlbean factory?
What is setbounds in java?
i want test pattern of zylog company and some examples also
Is java a web technology?
What is j2ee application model?
What is callback methods?
What do you mean by the component contract?
Difference between save and saveorupdate?
Why class is used in java?
Which edition of java is used for web application?
What is the preferred size of a component in java?
Which java technology is in demand?
What is java awt event?
What are the advanced technologies in java?