示例代码
public class Main {
    public static void main(String[] args){
        Map<String,Object> map = new HashMap<>();
        map.put("a",1);
        map.put("b",2);
        map.put("c",3);
        Collection<Object> values = map.values();
        System.out.println(values);
    }
}
通过debug发现,调用
map.values()
时进入了HashMap的方法
public Collection<V> values() {
    Collection<V> vs = values;  if (vs == null) {
        vs = new Values();  values = vs;
    }  return vs;
}
第一次执行时,values为null,会进行创建
final class Values extends AbstractCollection<V> {
    public final int size()                 { return size; }
    public final void clear()               { HashMap.this.clear(); }
    public final Iterator<V> iterator()     { return new ValueIterator(); }
    public final boolean contains(Object o) { return containsValue(o); }
    public final Spliterator<V> spliterator() {
        return new ValueSpliterator<>(HashMap.this, 0, -1, 0, 0);
    }
    public final void forEach(Consumer<? super V> action) {
        Node<K,V>[] tab;
        if (action == null)
            throw new NullPointerException();
        if (size > 0 && (tab = table) != null) {
            int mc = modCount;
            for (int i = 0; i < tab.length; ++i) {
                for (Node<K,V> e = tab[i]; e != null; e = e.next)
                    action.accept(e.value);
            }
            if (modCount != mc)
                throw new ConcurrentModificationException();
        }
    }
}
vs = new Values();
执行过后vs就有值了,一直没想明白,卡在这里了。