filmov
tv
Java - Compare the Objects using equals() & hashCode()

Показать описание
- By default equals method only compare the reference object
- To compare based on Object value, override the equals & hashcode method
- First compare by hashcode(), if hashCode of both Objects are different, then objects are not equal
- but if hashcode of both Objects are same, then we check the equals method
- hashcode is used to quickly checl the equality
- Now whenever you're adding Object in Set or Map, then also you need to overide the equals & hashcode
- Because, Set & Map check the equality & if Object are equal it won't add again so you need to add equality
CHECK OUT CODING SIMPLIFIED
★☆★ VIEW THE BLOG POST: ★☆★
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
★☆★ Send us mail at: ★☆★
- To compare based on Object value, override the equals & hashcode method
- First compare by hashcode(), if hashCode of both Objects are different, then objects are not equal
- but if hashcode of both Objects are same, then we check the equals method
- hashcode is used to quickly checl the equality
- Now whenever you're adding Object in Set or Map, then also you need to overide the equals & hashcode
- Because, Set & Map check the equality & if Object are equal it won't add again so you need to add equality
CHECK OUT CODING SIMPLIFIED
★☆★ VIEW THE BLOG POST: ★☆★
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
★☆★ Send us mail at: ★☆★
Java - Compare the Objects using equals() & hashCode()
.equals() vs. == in Java - The Real Difference
#95 Comparator vs Comparable in Java
Overriding the Object equals Method - Java Override Example - Comparing Objects - APPFICIAL
Java String Comparison Tutorial (Equals vs == in Java)
Comparable Interface in Java - Tutorial for Beginners | Learn Comparable in 5 minutes
Interview Question | Comparable vs Comparator in Java
finalize method #javaprogramming #java #shorts
Java Tutorial - Compare Objects - Equality Operator Vs Equals Method
Difference Between '== Operator' And 'equals() Method' In Java (Hindi)
Java Classes & Objects
#7 - How to Compare Two ArrayLists in Java
Java Tutorial 11 - Comparing Two Strings
#038 [JAVA] - Passing Objects to Methods (Returning Objects / Comparing Objects)
Objects and Classes in Java
Interview Question : Compare Two Integer Numbers (Integer Caching) in #Java
Difference between '== operator' and 'equals() method' in java?
Comparing objects with equals() method - Basic Java Fast (20)
Association(HAS-A) Aggregation And Composition in Java [MOST COMMONLY ASKED INTERVIEW QUESTION]
Equals and Hashcode Contract in Java [Important Java Interview Question] | Code Decode
Java Constructors - Full Tutorial
Java array of objects 🍱
Java objects (OOP) ☕
Java copy objects 🖨️
Комментарии