JAVA) Immutable

·2021년 11월 11일
0

Study

목록 보기
5/20

Immutable: 불변

String은 immutable하다.

String str = "hi";
str = "hi hello and u";

여기서 "hello and u"가 추가된 것이 아니라 "hi"가 있는 메모리 공간을 가리키고 있던 str이 "hi hello and u"라는 문자열이 있는 메모리 공간을 가리키게 되는 것이다.

참고: https://live-everyday.tistory.com/214

profile
HAPPY !

0개의 댓글