Here you can find the source of buildMap(List extends T> a, Map
private static <T> void buildMap(List<? extends T> a, Map<T, Integer> coeffs)
//package com.java2s; /* License as published by the Free Software Foundation; either */ import java.util.List; import java.util.Map; public class Main { private static <T> void buildMap(List<? extends T> a, Map<T, Integer> coeffs) { for (T t : a) { Integer coeff = coeffs.get(t); if (coeff == null) { coeffs.put(t, 1);/*from w ww.j a v a 2s.co m*/ } else { coeffs.put(t, coeff + 1); } } } }