0% found this document useful (0 votes)
2 views1 page

Java Program to Reverse a String

The document contains a Java program that reverses a given string, 'Hello World'. It uses a for loop to iterate through the string in reverse order and constructs a new string with the characters in reverse. Finally, it prints the reversed string to the console.

Uploaded by

harritjevi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Java Program to Reverse a String

The document contains a Java program that reverses a given string, 'Hello World'. It uses a for loop to iterate through the string in reverse order and constructs a new string with the characters in reverse. Finally, it prints the reversed string to the console.

Uploaded by

harritjevi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program to reverse the string:

public class ReverseString {

public static void main(String[] args) {

String input = "Hello World";

String reversed = "";

for (int i = [Link]() - 1; i >= 0; i--) {

reversed += [Link](i);

[Link]("Reversed string: " + reversed);

You might also like