String은 " " 로
String에서 덧셈하면 문자열이 concat 된다.
char은 ' ' 으로
캐릭터 변수는 기본 출력이 문자이다.
문자끼리 빼면 아스키코드끼리 연산을 한다.
String은 한 번 인스턴스가 생성되면 수정할 수 없다. -> ( [ ] 대괄호 자체를 제공하지 않는다.)
값의 변경은 불가능하지만, 새 String을 만들어 바꿀 수는 있다.
1. str = "ABCDEFG"
2. str.toCharArray();
3. str.substring()
이용
String str_literal1 = "test"
String str_literal2 = "test" 로 생성하면 같은 pool 공간을 가리키게 저장되나 ( 두 변수를 ==비교를 하면 주소가 같아서 true값이 나온다)
String str_object1 = new String("test")
String str_object2 = new String("test")와 같이 생성하면 Heap의 다른 영역에 생성된다.
문자열 비교는 .equals로 한다.
String (Java Platform SE 8 ) (oracle.com)
String (Java Platform SE 8 )
Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argum
docs.oracle.com
여러 String 관련 메소드들은 위에서 확인할 수 있다.
'Java' 카테고리의 다른 글
| 자바/Java 재귀함수 Recursive (0) | 2024.03.09 |
|---|---|
| 자바 HashSet, TreeSet (0) | 2024.01.29 |
| 이클립스 초기 화면으로 돌리는 법 (perspective 화면 초기화) (0) | 2023.09.27 |
| [Java] HashMap 활용한 전화번호부 예제 (24-1) (0) | 2023.09.14 |
| [Java] TreeSet 사용 예제 (23-3) (0) | 2023.09.14 |