title: How to replace a string with char from a hashmap?
body: <p>I have a morse code program that can encode. Now I want it to decode but I do not know how to replace a string of encrypted characters with the letter from my hash map.</p>
  
  <p>Here is the method for decoding:</p>
  
  <pre><code>for(int i = 0; i &lt; userInput.length(); i++){
          if(i != 0){
              morse.append(' ');
          }
          morse.append(codeLibrary.get(userInput.charAt(i))); //Currentely the same as encoding, this line needs to change
      }
      return morse.toString();
  </code></pre>
  
  <p>And here is my hashmap:</p>
  
  <pre><code>public static final java.util.Map&lt;Character, String&gt; codeLibrary;
   static{
      codeLibrary = new HashMap&lt;&gt;();
      codeLibrary.put('a',".-");      codeLibrary.put('b',"-...");
      codeLibrary.put('c',"-.-.");    codeLibrary.put('d',"-..");
      codeLibrary.put('e',".");       codeLibrary.put('f',"..-.");
      codeLibrary.put('g',"--.");     codeLibrary.put('h',"....");
      codeLibrary.put('i',"..");      codeLibrary.put('j',".---");
      codeLibrary.put('k',"-.-");     codeLibrary.put('l',".-..");
      codeLibrary.put('m',"--");      codeLibrary.put('n',"-.");  
      codeLibrary.put('o',"---");     codeLibrary.put('p',".--.");
      codeLibrary.put('q',"--.-");    codeLibrary.put('r',".-.");
      codeLibrary.put('s',"...");     codeLibrary.put('t',"-");
      codeLibrary.put('u',"..-");     codeLibrary.put('v',"...-");
      codeLibrary.put('w',".--");     codeLibrary.put('x',"-..-");
      codeLibrary.put('y',"-.--");    codeLibrary.put('z',"--..");
      codeLibrary.put('1',".----");   codeLibrary.put('2',"..---");
      codeLibrary.put('3',"...--");   codeLibrary.put('4',".----");
      codeLibrary.put('5',".....");   codeLibrary.put('6',"-....");
      codeLibrary.put('7',"--...");   codeLibrary.put('8',"---..");
      codeLibrary.put('9',"----.");   codeLibrary.put('0',"-----");
      codeLibrary.put(' ',"/");
  </code></pre>