Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

Write a Java program to print the given string in reverse?

Strings are sequences of characters and are considered objects in Java. You can perform a wide variety of operations on a String object. Reversing a string object is one of the most commonly used operations.

Below is the Java program that prints the given string in reverse order.

import java.util.Scanner;
public class Reverse
 public static void main(String[] args)
 System.out.println("Enter a string you want to reverse:");
 Scanner sc = new Scanner(;
 String str = sc.nextLine();
 String rev = "";
 for(int i = str.length() - 1; i >= 0; i--)
 rev = rev + str.charAt(i);
 System.out.println("Reversed String:");

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS


24/7 support


Enterprise grade security


Fastest test execution cloud