title: I have written this code but it does output the value associated with sam key value pair? please tell me how to get the value of sam?
body: <pre><code>public static void main(String[] argh) {
    Map&lt;String, Integer&gt; myMap = new HashMap&lt;String, Integer&gt;();
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    String name = "sam";
    int phone = 0;
    for (int i = 0; i &lt; n; i++) {
      name = in.next();
      phone = in.nextInt();
      myMap.put(name, phone);
  
      while (in.hasNext()) {
        String s = in.next();
        if (myMap.containsKey(s)) {
          System.out.println(name + "=" + phone);
        } else {
          System.out.println("Not found");
        }
      }
      in.close();
    }
  }
  </code></pre>
  
  <p>I have written this code but it does output the value associated with sam key value pair?</p>
  
  <p>please tell me how to get the value of sam?</p>