Collectors.toMap NullPointerException

解决办法如下:
https://blog.csdn.net/zijikanwa/article/details/103034971

酱紫修改:

 Map<String, Object> map = o.getValue().stream().flatMap(m->{
                        return m.entrySet().stream();
                    }).collect(HashMap::new,
                            (n, v) -> n.put(v.getKey(), v.getValue()), HashMap::putAll);

jdk1.8源码:
HsahMap 1223行


    @Override
    public V merge(K key, V value,
                   BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
        if (value == null) //日
            throw new NullPointerException();
        if (remappingFunction == null)
            throw new NullPointerException();
        int hash = hash(key);
        Node<K,V>[] tab; Node<K,V> first; int n, i;
        int binCount = 0;
        TreeNode<K,V> t = null;
        Node<K,V> old = null;

收工。

你可能感兴趣的:(java)