import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class JI9047244 {

	public static void main(String[] args) {
		List<Pair<String, String>> list = new ArrayList<>(); 
		list.add(new Pair<>("KEY1", "VALUE")); 
		list.add(new Pair<>("KEY1", "VALUE")); 
		System.out.println(list);
		try { 
			Map<String, String> map = list.stream().collect(Collectors.toMap(Pair::getKey, Pair::getValue)); 
			System.out.println(map);
		} catch (IllegalStateException e) { 
			e.printStackTrace();
			System.out.println(e.getMessage().equals("Duplicate key KEY1")); 
		} 

	}

}

class Pair<K,V> {
	private K key;
	private V value;
	
	Pair(K key, V value) {
		this.key = key;
		this.value = value;
	}
	
	public K getKey() {
		return key;
	}
	
	public V getValue() {
		return value;
	}
	
	public String toString() {
		return key + "=" + value;
	}
}
