Java Stream - Compile time Error - Type mismatch: cannot convert from Map<Object,Object> to Map<Integer,List<String>>
<p>I hava a simple code where i am converting a List of my custom class object into a Map>.
The code is as follows:</p>

<pre><code>List&lt;NPDto&gt; appList = new ArrayList&lt;NPDto&gt;(); 
//list gets populated though some other method

//Here is conerting code where i get compile time error
final Map&lt;Integer, List&lt;String&gt;&gt; appMap = appList.stream()
                                              .collect(
                                                Collectors.toMap(
                                                  np -&gt; NumberUtils.toInt(np.getPId()),
                                                  np -&gt; Arrays.asList(np.getAppsReceived().split(","))
                                              ));
// Here is my DTO                                              
public class NPDto {

    private String pId;
  private String appsReceived;

  public String getPId(){
    return pId;
  }

  public void setPId(String pId){
    this.pId = pId;
  }

  public String getAppsReceived(){
    return appsReceived;
  }

  public void setAppsReceived(String appsReceived){
    this.appsReceived = appsReceived;
  }
}
</code></pre>

<p>But, i am getting a compiler error as follows:</p>

<pre><code>Type mismatch: cannot convert from Map&lt;Object,Object&gt; to Map&lt;Integer,List&lt;String&gt;&gt;
</code></pre>

<blockquote>
  <p>I am compiling with Java SE 8[1.8.0_91]</p>
</blockquote>

<p>Don't know where i am wrong. Can anybody please help out?</p>