My String Reversing Program in Java
Posted: Mon Oct 22, 2012 5:30 pm
Hi
I am back into my Java studies and wrote a little program to test my memory and also for fun.
So here is the program, This takes a string and then reverse it.
I am back into my Java studies and wrote a little program to test my memory and also for fun.
So here is the program, This takes a string and then reverse it.
Code: Select all
import java.util.Scanner;
public class StringReverse{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.println("Enter your String: ");
String s = input.nextLine();
char c[]= s.toCharArray();
for(int i=c.length-1; i>=0; i--){
System.out.print(c[i]);
}
System.out.println();
}
}