title: Retreiving values from HashMap<String, String> for each character of a string returns NULL
body: <p>I'm learning Java and as a project I'm trying to make a program that uses a <code>HashMap</code> to accept a <code>string</code> from the user then return the corresponding (pseudo-Pinyin) values as a quasi-encrypted <code>String</code>.</p>
  
  <p>I got this to work when the <code>String</code> was just 1 <code>character</code> in length, but my many attempts to handle full sentence failed.</p>
  
  <p>In a prior SO Question, this was marked as duplicate (and I deleted the question), but the prior related solution:</p>
  
  <pre><code> for (int i = 0; i &lt; args.length(); i++){
       char c = args.charAt(i);        
       s += lookup.get(c);
       s += " "; 
   }
  </code></pre>
  
  <p>Actually doesn't solve my problem.</p>
  
  <p>The best result I've been able to get using the <code>for</code> loop indicated as a previously posted solution was to return a string that prints <code>null</code> for every character entered by the user. For example, <code>hello</code> becomes <code>null null null null null</code>.</p>
  
  <p>Here's the relevant part of the code (<code>Encrypt2Pinyin.java</code>):</p>
  
  <pre><code>package pinyincrypto;
  import java.util.*;
  
  public class Encrypt2Pinyin {
  
  public static String e2p(String args){
  HashMap&lt;String, String&gt; lookup = new HashMap&lt;&gt;();
  lookup.put("a", "xuduo");
  lookup.put("b", "bai");
  lookup.put("c", "cai");
  lookup.put("d", "dai");
  lookup.put("e", "tao");
  lookup.put("f", "nao");
  lookup.put("g", "lao");
  lookup.put("h", "zheng");
  lookup.put("i", "ceng");
  lookup.put("j", "sheng");
  lookup.put("k", "peng");
  lookup.put("l", "che");
  lookup.put("m", "shui");
  lookup.put("n", "ge");
  lookup.put("o", "zhi");
  lookup.put("p", "nu");
  lookup.put("q", "ren");
  lookup.put("r", "nan");
  lookup.put("s", "hai");
  lookup.put("t", "xihuan");
  lookup.put("u", "wo");
  lookup.put("v", "wu");
  lookup.put("w", "chi");
  lookup.put("x", "niu");
  lookup.put("y", "duo");
  lookup.put("z", "yunxing");
  lookup.put("A", "Xuduo");
  lookup.put("B", "Bai");
  lookup.put("C", "Cai");
  lookup.put("D", "Dai");
  lookup.put("E", "Tao");
  lookup.put("F", "Nao");
  lookup.put("G", "Lao");
  lookup.put("H", "Zheng");
  lookup.put("I", "Ceng");
  lookup.put("J", "Sheng");
  lookup.put("K", "Peng");
  lookup.put("L", "Che");
  lookup.put("M", "Shui");
  lookup.put("N", "Ge");
  lookup.put("O", "Zhi");
  lookup.put("P", "Nu");
  lookup.put("Q", "Ren");
  lookup.put("R", "Nan");
  lookup.put("S", "Hai");
  lookup.put("T", "Xihuan");
  lookup.put("U", "Wo");
  lookup.put("V", "Wu");
  lookup.put("W", "Chi");
  lookup.put("X", "Niu");
  lookup.put("Y", "Duo");
  lookup.put("Z", "Yunxing");
  lookup.put(" ", " ");
  lookup.put(".", "?");
  lookup.put("!", ".");
  lookup.put("?", "!");
  lookup.put("$", "%");
  lookup.put("%", "$");
  lookup.put("@", "&amp;");
  lookup.put("&amp;", "@");
  lookup.put("#", "*");
  lookup.put("*", "#");
  lookup.put("^", "]");
  lookup.put("(", ")");
  lookup.put(")", "(");
  lookup.put("-", "-");
  lookup.put("=", "+");
  lookup.put("+", "=");
  lookup.put("\n", "\n");
  lookup.put(" ", " ");
  //Vector vec = new Vector();
  //vec.add(args);
  //Iterator&lt;HashMap&lt;K, V&gt;&gt; itr = lookup.values().iterator();
  //String[] vec = args;
  //Vector&lt;String&gt; vector = null;
  //while (itr.hasNext())
  //{
  //vector=(vec)itr.next();
  //  }
  
  //String[] str   = null;
  //s = args.split("(?!^)") ;
  
  String s   = " ";
  //String str = args.trim();
  for (int i = 0; i &lt; args.length(); i++){
      char c = args.charAt(i);        
          s += lookup.get(c);
          s += " ";
  }
  //return(lookup.get(args.charAt(1))); // just a test -- still returns null
  return(s);
  }
  }
  </code></pre>
  
  <p>If it's useful I can also provide the corresponding code for the <code>.java</code> file containing my <code>main</code> function.</p>