Which is the Best Java Web Framework ?

Java - Difference between StringUtils.EMPTY and StringUtils.isEmpty()

StringUtils.EMPTY vs StringUtils.isEmpty()

StringUtils.EMPTY is a final static member of StringUtil class that equates to "" i.e empty String.


StringUtils.isEmpty() Checks if a String is empty ("") or null.

How does StringUtils.EMPTY.equals(string) different from StringUtils.isEmpty(string)  

public class ParentTest {

         public static void main(String[] args){
              String str = "";
              String str2 = null;
                   System.out.println("str1.1 is empty");
                   System.out.println("str1.2 is empty");
                   System.out.println("str2.1 is empty");
                   System.out.println("str2.2 is empty");

results in 

str1.1 is empty

str1.2 is empty

str2.2 is empty

Though StringUtils.isEmpty(str2) is saying that its checking for empty str2 but its actually checking both null as well as blank string for str2.
Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus


Try our new Java Interview Questions Search Tool.

There are more than 1000 questions with practice tests.

It's updated daily and It's Awesome.


Try our new Java Practice Test tool.

There are more than 200 questions and expanding quickly. It's updated daily and It's Awesome.