Write a Java Program to Reverse a String Without Using String Inbuilt Function?

Write a Java Program to Reverse a String Without Using String Inbuilt Function



Write a Java Program to Reverse a String Without Using String Inbuilt Function

Public class  FinalReverseWithoutUsingStringMethods  {

         Public Static Void Main(String[ ] args)  {
               String str="Automation";
               StringBuilder str2 = new StringBuilder( ) ;
               str2.append(str) ;
               str2= str2.reverse( ) ;
               System.out.println(str2) ;
                  } 
             
}

Output: noitamotuA

Note:


  • The Object of the string builder class str2 will be further used to append the value stored in the string variable str.
  • Thereafter, we are using the inbuilt function of the string builder (revers()) and storing the new reversed string in str2. Finally, we are printing str2. 

For More information about the recruitment, admit card, hall ticket, result, and interview date please visit our website www.fresher-naukri.com.
   

0 comments 10:

Post a Comment