Visitors

Google PageRank Checker

Thursday, December 9, 2010

Simple Java Program - String Reverse using charAt - Java

Below is a source code for java. This Java program is very simple and basic. Reverse the string input by user using charAt. Enjoy!!!

//file begins here, save it as reverse.java
import java.io.*;
public class reverse
{
public static void main(String[]args) throws IOException
{
BufferedReader get = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your name: ");
String name = get.readLine();
balihon(name);
}
public static void balihon(String g)
{
String reverse;
reverse = "";
for(int i = g.length()-1; i >= 0; i--)
{
reverse = reverse + g.charAt(i);
}
System.out.println("\n" + reverse);
}
}
//program ends here...

0 comments: