Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What does application client module contain?

948


What is bean factory, have you used xmlbean factory?

872


What is setbounds in java?

977


i want test pattern of zylog company and some examples also

2700


Is java a web technology?

877


What is j2ee application model?

852


What is callback methods?

958


What do you mean by the component contract?

914


Difference between save and saveorupdate?

929


Why class is used in java?

841


Which edition of java is used for web application?

888


What is the preferred size of a component in java?

832


Which java technology is in demand?

898


What is java awt event?

852


What are the advanced technologies in java?

858