Java String reverse with and without reverse() Example

To reverse a string with less code in Java, there comes reverse() method in StringBuffer class. reverse() method cannot be used directly on string as reverse() is not defined in String class but defined in StringBuffer and StringBuilder. String should be converted to StringBuffer and then applied reverse() method. 1. Reversing using reverse() method. public …

Java String reverse with and without reverse() Example Read More »