Home >Java >JavaBase >What are the methods to determine whether a string is empty in java

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

王林
王林Original
2019-11-21 15:58:493112browse

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

Method one:

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

Method two:

   if(s == null ||"".equals(s));

Method three: Compare string length

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

Method Four:

   if(s == null || s.isEmpty());

Method five:

   if (s == null || s == "");

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!

Statement:
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