/* package whatever; // don't place package name! */

import java.util.*;
import java.util.stream.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    static class MyObject {
        private String key;
        private String value1;
        private String value2;

        MyObject(String key, String value1, String value2) {
            this.key = key;
            this.value1 = value1;
            this.value2 = value2;
        }
    }

    static class MyCreatedObject {
        private String key;
        private List<String> value1List = new ArrayList<>();
        private List<String> value2List = new ArrayList<>();

        MyCreatedObject(MyObject o) {
            key = o.key;
            value1List.add(o.value1);
            value2List.add(o.value2);
        }

        MyCreatedObject merge(MyCreatedObject other) {
            key = other.key;
            value1List.addAll(other.value1List);
            value2List.addAll(other.value2List);
            return this;
        }

        @Override
        public String toString() {
            return String.format("{key=%s, value1List=%s, value2List=%s}",
                    key, value1List, value2List);
        }
    }

    public static void main(String[] args) {
        List<MyObject> list = Arrays.asList(
                new MyObject("1", "WWW", "EEE"),
                new MyObject("1", "WWW", "AAA"),
                new MyObject("2", "WWW", "EEE"));

        Map<String, MyCreatedObject> grouped = list.stream()
                .collect(Collectors.toMap(o -> o.key, MyCreatedObject::new, MyCreatedObject::merge));

        System.out.println(grouped.values());
    }
}