2. Write a method that takes a String as an input and reverses the String. This reserved result should be the output. code example
Example 1: string reverse in java
String str = "Hello";
String reverse(String str){
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.reverse();
return sb.toString();
}
Example 2: reverse a string in java
As we know that String is immutable. String class do not have reverse() method.