title: Java Generic Map with Generic Type as key/ values
body: <p>I want to write a method which takes a Map as an parameter, which can contain any object as its value. I am trying to implement it using generics, but I am unable to implement it.</p>
  
  <p>Below is the code that I have tried so far.  This code as two methods:  <code>genericTest</code>, where I am trying to implement a generic solution, and  <code>nonGenericTest</code>, which is what I actually want to do with the generic solution but is implemented without using generics. Basically, the second method is the one which I want to convert to generics.</p>
  
  <p>What am I doing wrong?</p>
  
  <pre><code>import java.util.Iterator;
  import java.util.Map;
  
  public class Test {
      //V cannot be resolve to a type
      public void genericTest(Map&lt;String, V&gt; params) {
      }
  
      public void nonGenericTest(Map&lt;String, Object&gt; params) {
  
          Iterator&lt;String&gt; it = params.keySet().iterator();
          while (it.hasNext()) {
              String key =  it.next();
              Object value = params.get(key);
              if(value instanceof String){
                  String val1=(String) value;
                  // do something 
              }else if(value instanceof Integer){
                  Integer val1 = (Integer) value;
              } 
          }
      }
  }
  </code></pre>
  
  <p>I am getting compiler error as shown in the code.</p>