0% found this document useful (0 votes)
4 views1 page

Reverse String in Java Example

This Java program defines a main method that takes a string "Automation", appends it to a StringBuilder object, reverses the StringBuilder using its reverse method, and prints out the reversed string "noitamotuA". The program demonstrates reversing a string without using built-in string methods by using a StringBuilder instead.

Uploaded by

divyar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Reverse String in Java Example

This Java program defines a main method that takes a string "Automation", appends it to a StringBuilder object, reverses the StringBuilder using its reverse method, and prints out the reversed string "noitamotuA". The program demonstrates reversing a string without using built-in string methods by using a StringBuilder instead.

Uploaded by

divyar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Finally, we are printing str2.

1 public 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 [Link](str);
8 str2 = [Link](); // used string builder to reverse
9 [Link](str2);
10 }
11
12 }
Output:
noitamotuA

You might also like