void () { Map<CharSequence, List<? extends CharSequence>> result = new HashMap<>(); for (CharSequence charSequence : getList()) { if (charSequence != null) { if (result.put(charSequence, asList(charSequence)) != null) { throw new IllegalStateException("Duplicate key"); } } } Map<? extends CharSequence, ? extends List<? extends CharSequence>> map = result; System.out.println(map); }