Strings 02 - Write a program to reverse a string in java using StringBuffer
Strings in Java - Program 02
➜ Program 02: Write a program to reverse a string in java using StringBuffer
public class Test {
public static void main(String[] args) {
String s = "Hello";
System.out.println("Original String: " + s);
StringBuilder sb = new StringBuilder(s);
sb.reverse();
System.out.println("Reverse String: " + sb);
}
}
--------Output--------
Original String: Hello
Reverse String: olleH
-----------------------
Original String: Hello
Reverse String: olleH
-----------------------
Comments
Post a Comment