1"use strict";(globalThis.webpackChunkdocusaurus_blog_rudevico=globalThis.webpackChunkdocusaurus_blog_rudevico||[]).push([[166],{427:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>d,contentTitle:()=>a,default:()=>m,frontMatter:()=>o,metadata:()=>t,toc:()=>r});var t=n(3872),l=n(4848),s=n(8453);const o={slug:"difference-between-collections-unmodifiablelist-and-List-of-immutablelist",title:"unmodifiableList\uc640 ImmutableList",authors:"hyoyoonnam",tags:["Java"],status:"\ud83d\udfe9_done",topics:["[[woowa]]","[[Lv 1]]","[[Java]]"],started:new Date("2026-03-13T00:00:00.000Z"),"deadline(or finished)":new Date("2026-03-16T22:00:00.000Z")},a="1. \uacf5\ud1b5\uc810: \uc218\uc815 \uba54\uc11c\ub4dc\ub97c \ud638\ucd9c\ud558\uba74 \uc608\uc678\uac00 \ubc1c\uc0dd\ud55c\ub2e4",d={authorsImageUrls:[void 0]},r=[{value:"2.1. \uad6c\ud604\uccb4 \ud074\ub798\uc2a4\uac00 \ub2e4\ub974\ub2e4",id:"21-\uad6c\ud604\uccb4-\ud074\ub798\uc2a4\uac00-\ub2e4\ub974\ub2e4",level:2},{value:"2.2. \uc6d0\ubcf8 \uceec\ub809\uc158\uacfc\uc758 \uad00\uacc4\uc131\uc774 \ub2e4\ub974\ub2e4",id:"22-\uc6d0\ubcf8-\uceec\ub809\uc158\uacfc\uc758-\uad00\uacc4\uc131\uc774-\ub2e4\ub974\ub2e4",level:2},{value:"UnmodifiableList",id:"unmodifiablelist",level:3},{value:"ImmutableList",id:"immutablelist",level:3},{value:"References",id:"references",level:2}];function c(e){const i={admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i.admonition,{title:"\uc774 \uae00\uc744 \uc77d\uc73c\uba74",type:"note",children:(0,l.jsxs)(i.ol,{children:["\n",(0,l.jsxs)(i.li,{children:["\n",(0,l.jsx)(i.p,{children:"'\uc218\uc815\uc774 \ubd88\uac00\ub2a5\ud55c' \uceec\ub809\uc158\uacfc '\ubd88\ubcc0' \uceec\ub809\uc158\uc758 \ucc28\uc774\ub97c view\uc640 capture\ub85c \uc124\uba85\ud560 \uc218 \uc788\uc5b4\uc694."}),"\n"]}),"\n",(0,l.jsxs)(i.li,{children:["\n",(0,l.jsx)(i.p,{children:"\ub2e4\uc74c \ub450 \ucf54\ub4dc\ub85c \uc0dd\uc131\ud55c \uceec\ub809\uc158 \uac1d\uccb4\uc758 \ucc28\uc774\ub97c \uc54c \uc218 \uc788\uc5b4\uc694."}),"\n",(0,l.jsxs)(i.ul,{children:["\n",(0,l.jsx)(i.li,{children:(0,l.jsx)(i.code,{children:"Collections.unmodifiableList()"})}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.code,{children:"List.of()"})," \ub610\ub294 ",(0,l.jsx)(i.code,{children:"List.copyOf()"})]}),"\n"]}),"\n"]}),"\n"]})}),"\n",(0,l.jsxs)(i.p,{children:["\uc218\uc815 \uba54\uc11c\ub4dc\ub97c \ud638\ucd9c\ud558\uba74 ",(0,l.jsx)(i.code,{children:"UnsupportedOperationException"})," \uc608\uc678\uac00 \ubc1c\uc0dd\ud55c\ub2e4."]}),"\n",(0,l.jsx)("iframe",{frameBorder:"0",src:"https://onecompiler.com/java/44gg6wqev?codeEditors=true&hideNew=true&hideNewFile=true",width:"100%",height:"600px",title:"Unmodifiable vs Immutable List Java Example"}),"\n",(0,l.jsx)(i.h1,{id:"2-\ucc28\uc774\uc810",children:"2. \ucc28\uc774\uc810"}),"\n",(0,l.jsx)(i.h2,{id:"21-\uad6c\ud604\uccb4-\ud074\ub798\uc2a4\uac00-\ub2e4\ub974\ub2e4",children:"2.1. \uad6c\ud604\uccb4 \ud074\ub798\uc2a4\uac00 \ub2e4\ub974\ub2e4"}),"\n",(0,l.jsx)("iframe",{frameBorder:"0",src:"https://onecompiler.com/java/44gh4m5rq?codeEditors=true&hideNew=true&hideNewFile=true",width:"100%",height:"600px",title:"Unmodifiable vs Immutable List Java Example"}),"\n",(0,l.jsx)(i.h2,{id:"22-\uc6d0\ubcf8-\uceec\ub809\uc158\uacfc\uc758-\uad00\uacc4\uc131\uc774-\ub2e4\ub974\ub2e4",children:"2.2. \uc6d0\ubcf8 \uceec\ub809\uc158\uacfc\uc758 \uad00\uacc4\uc131\uc774 \ub2e4\ub974\ub2e4"}),"\n",(0,l.jsx)(i.h3,{id:"unmodifiablelist",children:"UnmodifiableList"}),"\n",(0,l.jsxs)(i.p,{children:[(0,l.jsx)(i.code,{children:"UnmodifiableRandomAccessList"})," \uad6c\ud604\uccb4(\uc774\ud558 ",(0,l.jsx)(i.code,{children:"UnmodifiableList"}),")\ub294 \uc6d0\ubcf8 \uceec\ub809\uc158\uc5d0 \ub300\ud55c ",(0,l.jsx)(i.strong,{children:"view"}),"\uc774\ub2e4."]}),"\n",(0,l.jsxs)(i.p,{children:["\ub2e4\uc74c\ucc98\ub7fc \uc6d0\ubcf8 \uceec\ub809\uc158\uc778 ",(0,l.jsx)(i.code,{children:"list"}),"\ub97c \ud544\ub4dc\ub85c \uac00\uc9c0\uace0, \uc678\ubd80\uc5d0\uc11c \uceec\ub809\uc158 \uba54\uc11c\ub4dc\ub97c \ud638\ucd9c\ud558\uba74 \uadf8\ub300\ub85c ",(0,l.jsx)(i.co
1de,{children:"list.method()"}),"\ub97c \ub300\uc2e0 \ud638\ucd9c\ud558\uc5ec \ub9ac\ud134\ud558\ub294 \ud504\ub85d\uc2dc\uc5d0 \ubd88\uacfc\ud558\ub2e4."]}),"\n",(0,l.jsxs)(i.p,{children:["\ub530\ub77c\uc11c, \uc6d0\ubcf8 \uceec\ub809\uc158\uc778 list\uc758 \ucc38\uc870\ub97c ",(0,l.jsx)(i.code,{children:"x001"}),", view(\ub610\ub294 \ud504\ub85d\uc2dc)\uc778 UnmodifiableList\uc758 \ucc38\uc870\ub97c ",(0,l.jsx)(i.code,{children:"x002"}),"\ub77c\uace0 \ud55c\ub2e4\uba74 ",(0,l.jsx)(i.code,{children:"x002.add()"}),"\ub294 \ubd88\uac00\ub2a5\ud558\uace0 ",(0,l.jsx)(i.code,{children:"x001.add()"}),"\ub294 \uac00\ub2a5\ud558\ub2e4."]}),"\n",(0,l.jsxs)(i.p,{children:["\ub610\ud55c ",(0,l.jsx)(i.code,{children:"x001"}),"\uc5d0 \ubcc0\ud654\uac00 \uc0dd\uae30\uba74, \uc774\ub97c \ud544\ub4dc\ub85c \uac00\uc9c0\ub294 ",(0,l.jsx)(i.code,{children:"x002"}),"\uc5d0\ub3c4 \ubc18\uc601\ub41c\ub2e4."]}),"\n",(0,l.jsx)(i.pre,{children:(0,l.jsx)(i.code,{className:"language-java",children:"static class UnmodifiableList<E> extends UnmodifiableCollection<E> \n implements List<E> { \n final List<? extends E> list; \n \n UnmodifiableList(List<? extends E> list) { \n super(list); \n this.list = list; \n } \n \n ...\n \n public E get(int index) {return list.get(index);}\n \n public void add(int index, E element) { \n throw new UnsupportedOperationException(); \n }\n ...\n}\n"})}),"\n",(0,l.jsx)("br",{}),"\n",(0,l.jsx)(i.p,{children:"\ub2e4\uc74c \uc608\uc2dc\ub97c \ubcf4\uc790."}),"\n",(0,l.jsx)("iframe",{frameBorder:"0",src:"https://onecompiler.com/java/44gh57eya?codeEditors=true&hideNew=true&hideNewFile=true",width:"100%",height:"600px",title:"Unmodifiable vs Immutable List Java Example"}),"\n",(0,l.jsx)(i.h3,{id:"immutablelist",children:"ImmutableList"}),"\n",(0,l.jsx)(i.p,{children:"\uce74\ud53c\ub97c \ud55c \uc21c\uac04\uc758 \uc6d0\ubcf8 \uceec\ub809\uc158\uc744 capture\ud55c \ub9ac\uc2a4\ud2b8\ub2e4. \uc989, \uc6d0\ubcf8 \ub9ac\uc2a4\ud2b8\ub85c\ubd80\ud130 \ub3c5\ub9bd\uc801\uc774\ub2e4."}),"\n",(0,l.jsx)(i.pre,{children:(0,l.jsx)(i.code,{className:"language-java",children:"// List.java\n...\nstatic <E> List<E> copyOf(Collection<? extends E> coll) { \n return ImmutableCollections.listCopy(coll); \n}\n...\n"})}),"\n",(0,l.jsx)(i.pre,{children:(0,l.jsx)(i.code,{className:"language-java",children:"// ImmutableCollections.java\n...\nstatic <E> List<E> listCopy(Collection<? extends E> coll) { \n ...\n } else { \n // \uacb0\uad6d \uc804\uccb4\ub97c \ubcf5\uc0ac\ud574\uc11c \ub118\uae34\ub2e4 = \uc6d0\ubcf8\uacfc \ub3c5\ub9bd\ub41c \uc0c8\ub85c\uc6b4 \uceec\ub809\uc158\n return (List<E>)List.of(coll.toArray()); \n } \n}\n...\n"})}),"\n",(0,l.jsx)(i.h1,{id:"2-listcopyof\uc5d0-\ubd88\ubcc0-\uceec\ub809\uc158\uc744-\uc804\ub2ec\ud558\uba74-\ubcf5\uc0ac\ub97c-\uc218\ud589\ud558\uc9c0-\uc54a\uace0-\uadf8\ub300\ub85c-\ubc18\ud658\ud55c\ub2e4",children:"2. List.copyOf()\uc5d0 \ubd88\ubcc0 \uceec\ub809\uc158\uc744 \uc804\ub2ec\ud558\uba74, \ubcf5\uc0ac\ub97c \uc218\ud589\ud558\uc9c0 \uc54a\uace0 \uadf8\ub300\ub85c \ubc18\ud658\ud55c\ub2e4"}),"\n",(0,l.jsxs)(i.p,{children:["\uc704\uc5d0\uc11c\ub294 \ubcf5\uc7a1\ud558\ub2e4\uace0 \ud310\ub2e8\ud574 \uc124\uba85\ud558\uc9c0 \uc54a\uc740 \ubd80\ubd84\uc774 \uc788\ub2e4. \uc77c\ub2e8 ",(0,l.jsx)(i.code,{children:"ImmutableCollections.listCopy()"}),"\uc758 \uba54\uc11c\ub4dc \ubc14\ub514 \uc804\uccb4\ub97c \ucca8\ubd80\ud55c\ub2e4. \uc5ec\uae30\uc11c \uccab \ubc88\uc9f8 ",(0,l.jsx)(i.code,{children:"if"})," \ubd84\uae30\ub97c \ubcf4\uc790."]}),"\n",(0,l.jsx)(i.pre,{children:(0,l.jsx)(i.code,{className:"language-java",children:"static <E> List<E> listCopy(Collection<? extends E> coll) { \n // List12\uc640 ListN\uc740 \ub458 \ub2e4 AbstractImmutableList\uc758 \uc790\uc2dd\uc774\ub2e4. \uc989, \ubd88\ubcc0 \ub9ac\uc2a4\ud2b8\ub2e4.\n // \uadf8\ub807\ub2e4. List.copyOf()\ub294 \ubd88\ubcc0 \ub9ac\uc2a4\ud2b8\uac00 \uc778\uc790\ub85c \uc624\uba74 \uc544\ubb34 \uc791\uc5c5\ub3c4 \uc218\ud589\ud558\uc9c0 \uc54a\uace0, \uc778\uc790\ub85c \ub4e4\uc5b4\uc628 \uceec\ub809\uc158\uc744 \uadf8\ub300\ub85c \ub9ac\ud134\ud55c\ub2e4.\n if (coll instanceof List12 || (coll instanceof ListN<?> c && !c.allowNulls)) { \n return (List<E>)coll; \n // \uc774 \ubc11\uc740 \ubb34\uc2dc\n } else if (coll.isEmpty()) {\n return List.of();
1 \n } else { \n return (List<E>)List.of(coll.toArray()); \n } \n}\n"})}),"\n",(0,l.jsx)("br",{}),"\n",(0,l.jsx)(i.p,{children:"\uc0ac\uc2e4 \uad6c\ud604\uc744 \uc9c1\uc811 \ubcf4\uc9c0 \uc54a\ub354\ub77c\ub3c4, Javadoc\uc758 Implementation Note\ub97c \ud1b5\ud574 \ud655\uc778\ud560 \uc218 \uc788\ub2e4."}),"\n",(0,l.jsx)(i.admonition,{title:"Implementation Note:",type:"note",children:(0,l.jsx)(i.p,{children:"If the given Collection is an unmodifiable List, calling copyOf will generally not create a copy."})}),"\n",(0,l.jsx)("br",{}),"\n",(0,l.jsxs)(i.p,{children:["\ub2e4\uc74c \uc608\uc2dc\ub97c \ubcf4\uc790. ",(0,l.jsx)(i.code,{children:"List.copyOf(\ubd88\ubcc0\ub9ac\uc2a4\ud2b8)"}),"\uc640 \uc6d0\ubcf8\uc758 \ucc38\uc870\uac00 \ub3d9\uc77c\ud55c \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4."]}),"\n",(0,l.jsx)("iframe",{frameBorder:"0",src:"https://onecompiler.com/embed/java/44gg6962y?codeEditors=true&hideNew=true&hideNewFile=true",width:"100%",height:"500px"}),"\n",(0,l.jsxs)(i.p,{children:["\ub2e4\uc74c \uc608\uc2dc\uc5d0\uc11c\ub294 ",(0,l.jsx)(i.code,{children:"List.copyOf(\ubd88\ubcc0\ub9ac\uc2a4\ud2b8)"}),"\uac00 \uc544\ubb34 \uac83\ub3c4 \uc218\ud589\ud558\uc9c0 \uc54a\uc74c\uc744 \uc218\uce58\uc801\uc73c\ub85c \ud655\uc778\ud560 \uc218 \uc788\ub2e4. \uc5ec\ub7ec \ubc88 \uba54\uc11c\ub4dc\ub97c \ud638\ucd9c\ud574\ub3c4 \ubcf5\uc0ac\uac00 \uc77c\uc5b4\ub098\uc9c0 \uc54a\uc73c\ubbc0\ub85c, 0ms\uac00 \uc18c\uc694\ub41c\ub2e4."]}),"\n",(0,l.jsx)("iframe",{frameBorder:"0",src:"https://onecompiler.com/embed/java/44gh5xgjx?codeEditors=true&hideNew=true&hideNewFile=true",width:"100%",height:"500px"}),"\n",(0,l.jsx)(i.h2,{id:"references",children:"References"})]})}function m(e={}){const{wrapper:i}={...(0,s.R)(),...e.components};return i?(0,l.jsx)(i,{...e,children:(0,l.jsx)(c,{...e})}):c(e)}},3872:e=>{e.exports=JSON.parse('{"permalink":"/difference-between-collections-unmodifiablelist-and-List-of-immutablelist","editUrl":"https://github.com/hyoyoonnam/blog/2026-03-13-unmodifiable-list\uc640-immutable-list/index.md","source":"@site/blog/2026-03-13-unmodifiable-list\uc640-immutable-list/index.md","title":"unmodifiableList\uc640 ImmutableList","description":"1. \'\uc218\uc815\uc774 \ubd88\uac00\ub2a5\ud55c\' \uceec\ub809\uc158\uacfc \'\ubd88\ubcc0\' \uceec\ub809\uc158\uc758 \ucc28\uc774\ub97c view\uc640 capture\ub85c \uc124\uba85\ud560 \uc218 \uc788\uc5b4\uc694.","date":"2026-03-13T00:00:00.000Z","tags":[{"inline":true,"label":"Java","permalink":"/tags/java"}],"readingTime":2.56,"hasTruncateMarker":true,"authors":[{"name":"HyoYoonNam","title":"Software Engineer","url":"https://linkedin.com/in/hyoyoonnam","page":null,"description":"Java, Spring\uc744 \uba54\uc778\uc73c\ub85c \ud558\ub294 \ucde8\uc900\uc0dd\uc785\ub2c8\ub2e4.","socials":{"linkedin":"https://www.linkedin.com/in/hyoyoonnam/","github":"https://github.com/hyoyoonnam","email":"mailto:[email protected]"},"imageURL":"https://github.com/hyoyoonnam.png","key":"hyoyoonnam"}],"frontMatter":{"slug":"difference-between-collections-unmodifiablelist-and-List-of-immutablelist","title":"unmodifiableList\uc640 ImmutableList","authors":"hyoyoonnam","tags":["Java"],"status":"\ud83d\udfe9_done","topics":["[[woowa]]","[[Lv 1]]","[[Java]]"],"started":"2026-03-13T00:00:00.000Z","deadline(or finished)":"2026-03-16T22:00:00.000Z"},"unlisted":false,"prevItem":{"title":"SQ3R\uc774\ub780","permalink":"/explanation-about-SQ3R"},"nextItem":{"title":"message \uc804\uc1a1\uacfc \uba54\uc11c\ub4dc \ud638\ucd9c\uc740 \ub2e4\ub974\ub2e4.","permalink":"/difference-between-message-sending-and-method-calling"}}')},8453:(e,i,n)=>{n.d(i,{R:()=>o,x:()=>a});var t=n(6540);const l={},s=t.createContext(l);function o(e){const i=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function a(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:o(e.components),t.createElement(s.Provider,{value:i},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.