Java Program To

Reverse A String

System.println("Reverse of entered string is: "+reverse). i >= 0 . Java programming code import java. } } Download Reverse string program class file. i-. original = in.out. for ( int i = length .This java program reverses a string entered by the user. Scanner in = new Scanner(System.nextLine(). We use charAt method to extract characters from the string and append them in reverse order to reverse the entered http://freepdf-books.util.println("Enter a string to reverse").charAt(i). reverse = "". int length = original.*. class ReverseString { public static void main(String args[]) { String . System.out.1 .) reverse = reverse + original.

reverse()).out. System.println(a.Output of program: Reverse string using StringBuffer class class InvertString { public static void main(String args[]) { StringBuffer a = new StringBuffer("Java programming is fun"). http://freepdf-books. } } StringBuffer class contains a method reverse which can be used to reverse or invert an object of this .