title: How to print a single Key-Value pair in a HashMap in java?
body: <p>Is it possible to do so? If yes, what is the required syntax/method?</p>
  
  <p>I tried it by using,</p>
  
  <p><code>System.out.println(key+"="+HM.get(key));</code></p>
  
  <p>but it prints it in this format,</p>
  
  <p>key= value</p>
  
  <p>whereas, I need</p>
  
  <p>key=value</p>
  
  <p>(Due to outputting format in HackerRank)</p>
  
  <pre><code>while(sc.hasNextLine()) 
  {
    String s=sc.nextLine();
    if(a.containsKey(s))
    {
        System.out.println(s+"="+a.get(s));
    }
    else
    System.out.println("Not found");
  }
  </code></pre>
  
  <p>EDIT 1:
  I saw the solution given, the person used the following code,</p>
  
  <pre><code>   while(scan.hasNext()){
              String s = scan.next();
              Integer phoneNumber = phoneBook.get(s);
              System.out.println(
                  (phoneNumber != null) 
                  ? s + "=" + phoneNumber 
                  : "Not found"
              );
          }
  </code></pre>
  
  <p>Now, why does this not have white space in the answer? </p>
  
  <p>The only visible change I see is that this person used an object instead of primitive data type.</p>
  
  <p>Also,this person used int instead of string in accepting the phone number, I initially did the same but it gave me an InputMismatchException .</p>