title: How to check if a string is a number
body: <p>I have conversion to Map problem in Core Java.</p>
  
  <p>Below is requirement:<br>
  Given a String array below  </p>
  
  <pre><code>String str[] = {"abc","123","def","456","ghi","789","lmn","101112","opq"};          
  </code></pre>
  
  <p>Convert it into a Map such that the resultant output is below          </p>
  
  <p>Output          </p>
  
  <pre>======      ======         
  key         Value        
  ======      ======                  
  abc          true       
  123          false       
  def          true      
  456          false
  </pre>        
  
  <p>The above should be printed for each element in the array. I have written the code but it's not working and I'm stuck. Please let me know how it can be resolved.        Thanks in advance.      </p>
  
  <pre><code>import java.util.HashMap;       
  import java.util.Iterator;       
  import java.util.Map;       
  
  public class CoversionToMap {
  
  /**
   * @param args
   */
  public static void main(String[] args) {
      String str[] = {"abc","123","def","456","ghi","789","lmn","101112","opq"};
      Map m = new HashMap();
      for(int i=0;i&lt;str.length;i++){
          if(Integer.parseInt(str[i]) &lt; 0){
              m.put(str[i],true);
          }else{
              m.put(str[i],false);
          }
      }
      //Print the map values finally
      printMap(m);
  }   
  
  public static void printMap(Map mp) {
          Iterator it = mp.entrySet().iterator();
          while (it.hasNext()) {
              Map.Entry pairs = (Map.Entry)it.next();          
              System.out.println(pairs.getKey() + " = " + pairs.getValue());
          }
  }  
  }           
  </code></pre>
  
  <p>exception:</p>
  
  <pre>
  Exception in thread "main" java.lang.NumberFormatException: For input string: "abc"       
      at java.lang.NumberFormatException.forInputString(Unknown Source)       
      at java.lang.Integer.parseInt(Unknown Source)       
      at java.lang.Integer.parseInt(Unknown Source)       
      at CoversionToMap.main(CoversionToMap.java:22)       
  </pre>