https://nowonbun.tistory.com/2921 String 비교 equals() Obeject 메서드 오버라이드 메서드 내부적으로 우선 '==' 키워드로 객체가 같은지 비교하고 객체가 다른 경우 인자가 String이면 문자열 비교하여 결과를 한다. 대소문자를 구분하지 않을 경우 equalsIgnoreCase()를 사용한다. 주의) 비교 시 객체가 null이라면 NullPointerException 발생, 인자가 null인 경우는 예외 발생하지 않음 String str1 = "hi"; String str2 = "hello"; String str3 = "hi"; System.out.println(str1.equals(str2));//false System.out.println(str2.equals(str1));//false System.out.println(str1.eq.. 2022. 7. 11. 이전 1 다음