title: How to create two arrays with shared data in Java
body: <p>First the reason I need to do this is because of the API in <a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringUtils.html#replaceEach%28java.lang.String,%20java.lang.String%5B%5D,%20java.lang.String%5B%5D%29" rel="nofollow">Apache's Commons StringUtils</a> method: </p>
  
  <pre><code>StringUtils.replaceEach(String text, String[] searchList, String[] replacementList) 
  </code></pre>
  
  <p>What I want to do is replace all the HTML special character encodings with the actual special character, which means that the <code>searchList</code> and <code>replacementList</code> arrays will be pretty large. How can I do this in an easy to read and maintain way?</p>
  
  <p>Yes I could create two arrays but if I do this then it will be very easy to make mistakes. How do I know I'm not missing a special encoding, that I have the right position, etc. <strong>I would much rather have code where the encoding and the character are side by side to avoid any errors.</strong> I looked at a <code>HashMap</code> but then you can only get the keys (encodings) and have to loop through to get the character values, which is not very performant, especially not if it's going to be run a lot. The same is true with a two dimensional array that you have to split each run.</p>