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 is core java and j2ee?
What are the topics in j2ee?
What is java listener?
Enlist the technologies embraced in j2ee?
Which java technology is in demand?
What is data?
Is a relationship java?
What is the best java course?
What is component in java with example?
explain the technologies that j2ee platform provides for developing components.
What is j2ee api?
What is context root?
What is group?
What is the preferred size of a component in java?
Which software is used for java?