Home >>Java Programs >Java Program to find Reverse of the string.
In this example, we will create a java program to find the reverse of the given string.
In this program we will iterate the string backward and store each character from the original string into a new string.
public class Main
{
public static void main(String[] args)
{
String string = "Abhimanyu";
String reversedStr = "";
for(int i = string.length()-1; i >= 0; i--)
{
reversedStr = reversedStr + string.charAt(i);
}
System.out.println("Original string: " + string);
System.out.println("Reverse of given string: " + reversedStr);
}
}