Java & Spring
[JAVA] isEmpty() 빈 문자열 체크
doitdoik
2022. 2. 28. 18:34
728x90
반응형
isEmpty()
- 문자열, 배열이 비어있는지 여부 체크.
- nulld을 체크하진 않는다.
- boolean 형으로 반환.
isEmpty() 예제
public class Main {
public static void main(String args[]) {
String str1 = "";
String str2 = " ";
String str3 = null;
System.out.println(str1.isEmpty()); // true
System.out.println(str2.isEmpty()); // false
System.out.println(str3.isEmpty()); // Error NullPointerException
}
}
728x90
반응형