Always use length() instead of equals() to check empty string in java
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.equals(“”)....
View ArticleHow to design a good key for HashMap
A very popular interview question indeed. It is asked immediately after “How HashMap works?”. Lets make a reasoning around a good key class design. The very basic need for designing a good key is that...
View ArticleHibernate Entities Equality and Identity
Many times in our application, we face a situation where we have to compare two objects to check their equality for satisfying some business rules. In core java, we have already much knowledge about...
View ArticleWorking with hashCode and equals methods in java
In this post, i will point out my understanding about hashCode() and equals() methods. I will talk about their default implementation and how to correctly override them. I will also write about...
View Article