java 문자열 null check1 [Java] 문자열을 검사하는 방법 - String isEmpty(), isBlank(), null 체크 ✅ isEmpty(), isBlank(), null 체크 정리검사 방법설명예시 코드주의 사항str.isEmpty()문자열의 길이가 0이면 true"".isEmpty() → true" ".isEmpty() → falsestr == null이면 NullPointerException 발생str.isBlank() (Java 11+)문자열이 공백만 포함되거나 비어 있으면 true"".isBlank() → true" ".isBlank() → true"\n\t".isBlank() → truestr == null이면 NullPointerException 발생str == null문자열이 null 객체인지 확인str == null → true.isEmpty()나 .isBlank() 호출하면 예외 발생하므로 먼저 체크 필요.. 2025. 4. 1. 이전 1 다음