방어적 복사

[Java] LinkedHashMap의 방어적 복사 0. 들어가기전에 이번 블랙잭 미션을 하면서 결과 출력을 할 때, LinkedHashMap을 방어적 복사를 하려고 Map.copyOf()를 쓴 적이 있었다. 하지만, 이 방법은 기존 순서를 유지하지 못했다. 이 글을 통해 순서가 깨지는 이유와 방어적 복사를 하는 방법을 알아보자. 1. LinkedHashMap이란? Hash table and linked list implementation of the Map interface, with predictable iteration order. This implementation differs from HashMap in that it maintains a doubly-linked list running thr..