title: Random Character Generator Behaving Strange
body: <p>I'm writing this algorithm that replaces a letter in a name with a random letter at a random location. It does what I need it to do, but after a couple iterations of this algorithm, it starts replacing every letter with 1 letter. <br/></p>
  
  <p><strong>For example:</strong> <em>greg
  rrer
  ttet
  dded
  yyey
  jjej
  ffef
  hheh
  rrer
  rrlr
  rrwr
  rrhr
  vvwv
  oowo
  bbwb
  yywy
  mmwm
  mmtm
  llwl
  mmwm
  mmim
  ggig
  eeie
  eeie
  ffif
  jjij
  jjwj
  bbib
  ggig
  ggbg
  kkbk
  ggag
  ccac
  hhah
  ccmc
  zzaz
  llal
  eeae
  wwaw
  wwpw
  ddpd
  ffpf
  yypy
  iipi
  ffsf
  rrsr
  ssss
  iiii
  bbbb
  iiii
  dddd
  xxxx
  ssss
  llll
  uuuu
  ssss</em>
  <br/></p>
  
  <p>I'm at a loss as to why it starts to do this after functioning properly. Any advice is much appreciated!</p>
  
  <p><br/></p>
  
  <pre><code>private static String replaceName() {
  
              final String alphabet = "abcdefghijklmnopqrstuvwxyz";
              final int alphaNum = alphabet.length();
              String newName = null;
  
              Random r = new Random();
  
              for (int i = 0; i &lt; (r.nextInt(name.length()) + 1); i++) {
  
                  int replaceCharAt = r.nextInt(name.length());
  
                  newName = name.replace(name.charAt(replaceCharAt), alphabet.charAt(r.nextInt(alphaNum)));
                  //System.out.println(newName);
  
              }
  
              return newName;
  
          }
  </code></pre>