title: What's wrong with my program?
body: <pre><code>public class Stringreverser {
      public char[] reverse(String a){
          char[] arre = a.toCharArray() ;
          char[] result = {} ;
          int count = 0 ;
          for(int inarre = arre.length -1 ; inarre &gt;= 0 ; inarre = inarre -1 ){
              result[count] = arre[inarre] ;
  
              count+= 1 ;
          }
          return result ;
      }
      public static void main(String argv[]){
          System.out.println(new Stringreverser().reverse("hello")) ;
      }
  }
  </code></pre>
  
  <p>This keeps giving me an - <code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0</code> error. 
  The program is supposed to take in a string and reverse and return a char array . The problem seems to be in <code>result[count] = arre[inarre] ;</code> . What is the problem  ?</p>