Optimize way to check empty string in Java

In this post, we’ll see the best practice and optimize way to check empty String in Java. Every developer know how to check empty String but here we’ll look into the optimized method of checking empty String. 

Most of us always prefer to use equals() method to check for empty String such as

However, this equals() method is overkill to test for an empty String. It is quicker to test if the length of the String is 0. So, the best way to check for empty String is 

Click here to read more


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s