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 j2ee tutorial?
How will you explain load() and get() methods?
What is j2ee server?
Is j2ee and jee same?
What type of code is java?
What is javaserver pages (jsp)?
What is a web container j2ee?
What is the use of jit compiler in java?
What are struts?
Why is java called object oriented?
Describe action form?
What is jaxr client?
What is enterprise information system resource?
when i m calling java for web browser . so browser it's not support. show error in browser: internal error occur. java.lang.NoClassDefFoundError. will you give me solution why it's not starting browser.? is there any consult with .net framework2.0?
public class ActionSearchBean extends
GenericSearchBean