Home > Java > JavaBase > body text

What are the methods to determine whether a string is empty in java

王林
Release: 2019-11-21 15:58:49
Original
3069 people have browsed it

What are the methods to determine whether a string is empty in java

Method one:

   if(StringUtils.isNotBlank(str))//判断字符串不为空
   或if(StringUtils.isBlank(str))//判断字符串为空
Copy after login

Method two:

   if(s == null ||"".equals(s));
Copy after login

Method three: Compare string length

   if(s == null || s.length() <= 0);
Copy after login

Method Four:

   if(s == null || s.isEmpty());
Copy after login

Method five:

   if (s == null || s == "");
Copy after login

Recommended tutorial: java quick start

The above is the detailed content of What are the methods to determine whether a string is empty in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template