== 는 주소가 동일한지 비교 (같은 객체인지)
.equals()는 값이 동일한지 비교
// These two have the same value
new String("test").equals("test") // --> true
// ... but they are not the same object
new String("test") == "test" // --> false
ref : https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java
'Java' 카테고리의 다른 글
[Java] 문자열을 문자 배열로, 문자 배열을 문자열로 변환 (0) | 2022.11.07 |
---|---|
[Java] 문자열 대문자/소문자 전환 (0) | 2022.11.02 |
[Java] startsWith 활용 (0) | 2022.10.15 |
[Java] Arrays.copyOfRange 활용 (0) | 2022.10.14 |
[Java] Arrays.sort 활용 (0) | 2022.10.14 |