-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathReverseString.java
More file actions
17 lines (15 loc) · 548 Bytes
/
ReverseString.java
File metadata and controls
17 lines (15 loc) · 548 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.dsa;
import java.util.Scanner;
public class ReverseString {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
String reversed_string="";
System.out.println("Enter the string");
String string= input.next();
for(int i=string.length()-1;i>=0;i--){
reversed_string = reversed_string + string.charAt(i);
}
System.out.println("The original string is "+string);
System.out.println("The reversed string is "+reversed_string);
}
}