Here, we are initializing a string variable str and are making use of the string builder class
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 | str2.append(str); |
8 | str2 = str2.reverse(); // used string builder to reverse |
9 | System.out.println(str2); |
10 | } |
11 |
12 | } |
Output:
noitamotuA