title: Java - Mix up letters
body: <p>Can someone give me an example of how to split Strings before you scramble the letters</p>
  
  <p>I can scramble the words but it changes the length of the words too</p>
  
  <p>Example:</p>
  
  <blockquote>
    <p>input : Hello my name is Jon</p>
    
    <p>output: e imanoJs  my nlolHe</p>
  </blockquote>
  
  <p>But it should be like this</p>
  
  <blockquote>
    <p>input : Hello my name is Jon</p>
    
    <p>output: Hlelo my nmae is Jon</p>
  </blockquote>
  
  <p>so the first and last letter should stay in place </p>
  
  <p>here is my code so far </p>
  
  <pre><code>public class MixUp{
      public static void main(String[] args){
          String cards="Hello my Name is Jon, nice to meet you";
          System.out.println("Input String = " + cards);
          cards = shuffle(cards);
          System.out.println("Shuffled String = " + cards);
       }
  
      static String shuffle(String cards){
          if (cards.length()&lt;=1)
              return cards;
  
          int split=cards.length()/2;
  
          String temp1=shuffle(cards.substring(0,split));
          String temp2=shuffle(cards.substring(split));
  
          if (Math.random() &gt; 0.5) 
              return temp1 + temp2;
          else
              return temp2 + temp1;
      }
  }
  </code></pre>