title: Replacing Reoccurring Words in Java between Two Arrays
body: <p>I have two arrays:   </p>
  
  <pre><code>String common[] = {"also", "bad", "because", "but", "by", "crazy", "day", "for", "from", "good", "how", "just", "most", "no", "other", "people", "some", "speak", "speech", "strange", "talk", "them", "then", "think", "way", "what", "where", "who", "why", "with", "yes", "you"};  
  </code></pre>
  
  <p>and    </p>
  
  <pre><code>String jabber[] = {"ancient", "ballerina", "banana", "bankroll", "berserker", "birthplace", "blathering", "bouncy", "boutique", "candelabra", "cannibal", "capacitor", "circuit", "crash", "craven", "creepy", "dance", "dangerous", "daring", "dastardly", "download", "dragon", "ego", "evaluate", "feudal", "fiery", "flux", "funky", "ghostly", "glass", "gold", "grizzly", "hatch", "Hogwarts", "horn", "impure", "jump", "muscle", "near", "nicest", "omnivore", "parasite", "patronus", "punch", "salad", "savage", "seven", "shameful", "since", "slither", "sonic", "spaceship", "square", "tango", "tape", "throughout", "upon", "volcano"};   
  </code></pre>
  
  <p>I have a scanner, which accepts user input, let's assume. Given a line as input, this method should be able to switch a common word with a jabberword for every occurrence for the same common word: for example, if the input is:<br>
  also also also<br>
  then, say it picks to replace also with ancient, it should say<br>
  ancient ancient ancient </p>
  
  <p><strong>Here is my code:</strong> </p>
  
  <pre><code>public static String getJabberwordyResponse(String line) {
      String[] common = {"also", "bad", "because", "but", "by", "crazy", "day", "for", "from", "good", "how", "just", "most", "no", "other", "people", "some", "speak", "speech", "strange", "talk", "them", "then", "think", "way", "what", "where", "who", "why", "with", "yes", "you"};
      String[] jabber = {"ancient", "ballerina", "banana", "bankroll", "berserker", "birthplace", "blathering", "bouncy", "boutique", "candelabra", "cannibal", "capacitor", "circuit", "crash", "craven", "creepy", "dance", "dangerous", "daring", "dastardly", "download", "dragon", "ego", "evaluate", "feudal", "fiery", "flux", "funky", "ghostly", "glass", "gold", "grizzly", "hatch", "Hogwarts", "horn", "impure", "jump", "muscle", "near", "nicest", "omnivore", "parasite", "patronus", "punch", "salad", "savage", "seven", "shameful", "since", "slither", "sonic", "spaceship", "square", "tango", "tape", "throughout", "upon", "volcano"};
      for(int i = 0; i &lt; common.length; i++) {
          int j = (i &gt;= jabber.length - 1) ? 0 : i;
          line.replace(common[i], jabber[i]);
  
      }
      return line;
  }
  </code></pre>
  
  <p>Thoughts?</p>