Skip to content

Commit c758629

Browse files
authored
Added the Reverse a string program
1 parent d4f6b3d commit c758629

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Reverse.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://www.facebook.com/mayankgbrc/posts/2726954114288546
2+
# Subscribed by Code House
3+
import java.util.*;
4+
class ReverseString
5+
{
6+
public static void main(String args[])
7+
{
8+
String original, reverse = "";
9+
Scanner in = new Scanner(System.in);
10+
11+
System.out.println("Enter a string to reverse");
12+
original = in.nextLine();
13+
14+
int length = original.length();
15+
16+
for (int i = length - 1 ; i >= 0 ; i--)
17+
reverse = reverse + original.charAt(i);
18+
19+
System.out.println("Reverse of the string: " + reverse);
20+
}
21+
}

0 commit comments

Comments
 (0)