UnsupportedOperationException

    [Java] HashSet 합집합 add(), addAll() 시 UnsupportedOperationException 날 경우

    HashSet을 합치려고 시도하다가 UnsupportedOperationException 를 마주했다. 해결 후 기록으로 남겨두면 좋을 것 같아서 여기에 남긴다. 예를 들어 코드가 이런식이다. 코드: Map hashMap1 = new HashMap(); Map hashMap2 = new HashMap(); Set mySet1 = new HashSet(); Set mySet2 = new HashSet(); hashMap1 = (맵1 불러오기 코드) hashMap2 = (맵2 불러오기 코드) mySet1 = hashMap1.keySet() mySet2 = hashMap2.keySet() mySet1.addAll(mySet2); // 오류 오류메시지: java.lang.UnsupportedOperationEx..