Reverse String in Java


From Following  Program you can get the good knowledge in String Processing.Here i am Converting text in two way.Whole text that given as in put is reversed or by reversing each word by eliminating space.For running this program you need "org.apache.commons.lang.StringUtils" Library.
// Comment

import org.apache.commons.lang.xwork.StringUtils;

public class ReverseString {

    
     public static void main(String[] args)
     {
        
         String sampletext = "Java is Great Language";
          
        
         String reversed = StringUtils.reverse(sampletext);
          
         
         String delimitedReverse = StringUtils.reverseDelimited(sampletext, ' ');
                  
         
         System.out.println("Normal: " + sampletext);
         System.out.println("Reversed: " + reversed);
         System.out.println("Delimited Reverse: " + delimitedReverse);
     }

 
}


Output
Normal: Java is a Great Language
Reversed: egaugnaL taerG a si avaJ
Delimited Reverse: Language Great a is Java
raja P Web Developer

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...