diff --git a/Java/Reverse_String.java b/Java/Reverse_String.java new file mode 100644 index 0000000..8a723f2 --- /dev/null +++ b/Java/Reverse_String.java @@ -0,0 +1,15 @@ +import java.util.Scanner; +public class Main{ + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + System.out.println("Enter the word to be reversed: "); + String ostr=sc.nextLine(); + String rstr=""; + char ch; + for (int i=ostr.length()-1;i>=0;i--){ + ch=ostr.charAt(i); + rstr=rstr+ch; + } + System.out.println("Original String was "+ostr+" and Reversed String is "+rstr); + } +}