title: Reverse a String without affecting special characters
body: <p>Why is it throwing an error? Any help would be appreciated</p>
  
  <pre><code>public class RAWS 
  {
  public String rawsc(String ori)
  {
      String temp="";
      for(int i=0;i&lt;ori.length();i++)
      {
          char c=ori.charAt(i);
          if(((c&gt;=65)&amp;&amp;(c&lt;=90))||((c&gt;=97)&amp;&amp;(c&lt;122)))
              temp=c+temp;
      }
      for(int i=0;i&lt;ori.length();i++)
      {
          char c=ori.charAt(i);
          if(((c&gt;=65)&amp;&amp;(c&lt;=90))||((c&gt;=97)&amp;&amp;(c&lt;122)))
              ori.replace(c, temp.charAt(i));
      }
      for(int i=0;i&lt;ori.length();i++)
      {
          System.out.println(ori.charAt(i));
      }
      return(ori);
  }
  public static void main(String[] args) 
  {
      String str="a,b$c";
      RAWS ob=new RAWS();
      String new1=ob.rawsc(str);
      for(int i=0;i&lt;new1.length();i++)
      {
          System.out.print(new1.charAt(i)+" ");
      }
  }
  }
  </code></pre>
  
  <p>Editor:</p>
  
  <pre><code>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 4 
  at java.lang.String.charAt(String.java:658) 
  at arraygs.RAWS.rawsc(RAWS.java:22) 
  at arraygs.RAWS.main(RAWS.java:30)
  </code></pre>