isEmpty() vs ==null
== null은 참조 변수가 null 참조를 가지고 있는지 확인하는데 사용되며, empty() 메서드는 객체 자체가 "비어 있는지" 확인하는데 사용됩니다. empty() 메서드는 특정 클래스에서만 사용할 수 있으며, 클래스가 그러한 메서드를 제공해야 합니다. null 참조 변수에 empty() 메서드를 호출하려고 하면 NullPointerException이 발생합니다. 따라서 null 체크를 먼저 수행한 후 empty() 메서드를 안전하게 호출할 수 있습니다. String str = null; if (str != null && str.isEmpty()) { System.out.println("str is not null and str is empty"); }
Dev/Java
2019. 7. 31. 09:25
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- JPA 오류
- 계층형
- JoinColumn
- StAX
- timestamp
- 엘라스틱서치
- oracle12
- JPA
- cloudsearch 비용
- 단축키
- Elasticsearch
- tomcat
- 서버 환경변수
- Big xml 파싱
- could not initialize proxy - no Session
- #csvreader
- aws cloudsearch
- iTerm
- getdate
- CloudSearch
- OneToMany
- ojdbc7
- Python
- org.hibernate.LazyInitializationException
- db connect
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함