String name = "gaurav"; String reversedString = new StringBuilder(name).reverse().toString(); System.out.println(reversedString);