JNTUK396

Study Materials, Notes & Previous Question Papers — All Branches (R16, R19, R20)

Write a Java Program to reverse a string without using String inbuilt function.

Here, we are initializing a string variable str and are making use of the string builder class

1public class FinalReverseWithoutUsingStringMethods {
2 
3          public static void main(String[] args) {
4                   // TODO Auto-generated method stub
5                   String str = "Automation";
6                   StringBuilder str2 = new StringBuilder();
7                   str2.append(str);
8                   str2 = str2.reverse();     // used string builder to reverse
9                   System.out.println(str2);
10          }
11 
12}
Output:
noitamotuA
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. Reviewed by D kumar on September 19, 2019 Rating: 5
Powered by Blogger.