import java.util.Scanner; public class ReverseOfString { public void reverseOfString(String string){ String reverseString = ""; int lenth=string.length(); for(int i=lenth-1;i>=0;i--){ reverseString=reverseString+string.charAt(i); } System.out.println(reverseString); } public static void main(String args[]){ ReverseOfString r = new ReverseOfString(); r.reverseOfString("we have to reverse this string"); } }