Check if string is empty java => http://consceperti.nnmcloud.ru/d?s=YToyOntzOjc6InJlZmVyZXIiO3M6MjE6Imh0dHA6Ly9iaXRiaW4uaXQyX2RsLyI7czozOiJrZXkiO3M6Mjk6IkNoZWNrIGlmIHN0cmluZyBpcyBlbXB0eSBqYXZhIjt9 This constructor creates a StringBuilder object with initial of 20. So was there a Grand Design Reason behind no String. Capacity is the size of the internal buffer while the length is the actual number of characters in the buffer. This program combines all approaches we have discussed so fart to check if Java String is empty or not. As suggested by others, if you are using Google Guava, Spring or Apache commons than just check their StringUtils class, you might get a method which does this for you e. Each solution has their pros and cons and a special use case e. String to check emptiness Does String 'This is non Empty String ' is empty? If you without compromising performance then String. This approach is effective but verbose and is often replaced by a utility shown below. Apache StringUtils addresses this problem too. If you definition of empty String also includes null then you can also use Apache Commons Lang's StringUtils class. I prefer apache commons utility. In this case, I'm borrowing from Apache Commons Lang's name for the method and using isNotBlank for the injected method name. You can use any of the above three methods but you must remember the pros and cons of each method. Anonymous, isBlank and isNotBlank is also a good choice but they return true even if String contains whitespace, i. So, in my opinion, this is the right way to check if String is empty or not. It can be described as the absence of a string instance. Always Use length() Instead of equals() to Check Empty String - I don't have a null check because an instance method, by its nature, will only work on a non-null instance. And any String with length 0 is always going to be empty string. In your day-to-day programming activities, you must be coming across multiple situation where you need to check if a string is empty. There are various ways to do this and some use string1. Best way to check if string is empty or not is to use length method. This method simply return the count of characters inside char array which constitutes the string. If the count or length is 0; you can safely conclude that string is empty. Lets see the source code of both methods inside class. And any String with length 0 is always going to be empty string. Whereas equals method takes a check if string is empty java of statements before concluding that string is empty. It does reference check, typecasting if necessary, create temporary arrays and then use while loop also. Do let me know if you think otherwise. Update: From java 6 onwards, isEmpty function is available in String class itself. Please use this function directly. Hi I have two Strings. I want to find the common letters in both the strings. It is not displaying 'n' character because in the S2 'N' is capital that's y it is not displaying. Can any one please resolve this one and please tell me how to display the same outpout using collections. Apache gives us reformed way of this by StringUtils. It provides 3 checks: null, whitespace and empty. As generally we require all these 3 checks so this is another option. Hi folks, Apache String utility is using following code, please have a look into it. It does reference check, typecasting if necessary, create temporary arrays and then use while loop also. Actually, it only performs a reference check and a instanceof check.