Skip to main content

Java Program: Reverse String in Java Using For Loop

How to make a reverse string in Java using for loop?

We have a reverse string tutorial using recursion in our collection of Java Tutorials here, however I made another reverse string java program using for loop for my another Java Tutorial, the Palindrome Test. Like the reverse string in recursion, this reverse string in for loop is also a very small program. But I prefer this one than the other. It is easier to understand and to trace than the one in recursion. I bet you would also prefer this. See the code below for the verdict.

Other Java String Programs

Java Source Code on Reverse String using For Loop

package reverse_string_in_java;

import java.util.Scanner;

public class Main {

    public static void main(String[] args)
       Scanner input = new Scanner(;

       System.out.print("Enter a String: ");
       String string = input.nextLine();

       System.out.println("Reverse String Result: ");
       for(int i=1; i<=string.length() ;i++)


Sample Output:


Other Java Source Code Samples:


boby on January 25, 2015:

make it more simple for students

Related Articles