A program to reverse a String (Without using API)

Posted by

Code:

 class reverseWithoutAPI  
 {  
   public static void main(String a[])  
   {  
     String str="Java 2 career";  
     String arr[]=str.split(" ");  
     System.out.print("Reversed String of "+str+":");  
      for(int i=arr.length-1;i>=0;i--)  
     {  
       char temp[]=arr[i].toCharArray(); 
       for(int j=temp.length-1;j>=0;j--)  
       {  
         System.out.print(temp[j]);  
       }  
       System.out.print(" ");  
     }  
   }  
 }  

OUTPUT:

 

 

 

You may also like following string programs:

  1. Java program to find the first letter alphabetically in String
  2. Program to remove duplicate character from string without loosing the order in which it inserted
  3. A program to reverse a string and change first character case to lower case and last to lower case.
  4.  A program to check String is palindrom or not?

 

2 comments

Leave a Reply