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
Hi Friends. I want complete technical flow of j2ee project with following technologies. jsp , servlet , Struts , Hibernate , (should follow mvc-2 design pattern) . with DAO ,DTO SERVICE layers .
What is difference between j2ee and java?
What is application client container?
What are the differences between Ear, Jar and War files? Under what circumstances should we use each one?
What is callback methods?
Can I run seam in a j2ee environment?
What are java front end tools?
What is a j2ee component?
How does event listener work in java?
What are the advanced technologies in java?
What is a java application client?
What is javamail?
What is mean by j2ee?
Enlist the technologies embraced in j2ee?
What are the main components of the j2ee application?