title: How to reverse any middle chars in any string randomly and left first and last char the same
body: <p>I want this sentence to out like . What is wrong here because it give me 
  <code>java.lang.ArrayIndexOutOfBoundsException</code></p>
  
  <pre><code>package first;
  
  import org.apache.commons.lang.RandomStringUtils;
  
  
  public class reverseString2 {
  
  public static void main(String []args){
  
  
  
          String str = "The student so lazy";
          String[] split = str.split(" ");
          String middle = null;
          StringBuilder output = new StringBuilder();
  
          for (String s : split) {
              middle = s.substring(1, s.length()-1 );
              s = s.replace(middle,RandomStringUtils.random(5, middle));
              output.append(s + " ");
          }
  
          System.out.println(output.toString());
      }
  
  
  
  }
  </code></pre>