String은 기본 데이터 타입일까?

bbangho·2023년 9월 19일

java

목록 보기
8/12

String은 Reference 타입이다!

The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class.

class라고 설명해준다.

String은 불변이라고 설명하는데 우리는 + 연산자나 다른 편리한 연산자가 많기 때문에 불변이라고는 쉽게 생각할 수 없다.

String str = "abc" 가 존재하고 str + "ee"를 하면

새로운 스트링 객체가 생성되고 그게 할당되는 것이다.

참고:
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html

profile
2024. 06.17

0개의 댓글