String1 자바 String 클래스 자바 String 클래스 문자열 생성 방법 문자열은 객체로 취급한다. String str1 = new String("Hello World") String str2 = new String("Hello World") stack메모리에 저장된 str1객체를 Heap 메모리에 새로운 Stirng객체를 생성(str1에서 HelloWorld를 가리킨다) new를 사용하면 Heap Memory에 저장 String str1 = "HelloWorld" // 리터럴 상수 String str2 = "HelloWorld" // 리터럴 상수 stack메모리에 저장된 str1객체를 Literal Pool 메모리에 새로운 문자열 객체를 생성 (str1에서 HelloWorld를 가리킨다) Literal Pool 재활용 메모리 공간 .. 2024. 1. 29. 이전 1 다음