// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class StreamCopy9 {
    public static void main(String[] args) {
        List<String> lst = List.of("A", "BB", "CCC");
        List<String> lst2 = Collections.unmodifiableList(lst.stream().collect(Collectors.toList()));
        for(String s : lst2) {
            System.out.println(s);
        }
        Map<Integer,String> mp = Map.of(1, "A", 2, "BB", 3, "CCC");
        Map<Integer,String> mp2 = Collections.unmodifiableMap(mp.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())));
        System.out.println(mp2.get(2));
    }
}
