🎯 Key Takeaways for quick navigation: Every class in Java implicitly extends the Object class. The Object class provides methods like equals, hashCode, toString, etc., even if not explicitly defined in a class. The toString method returns a string representation of the object, including the class name and hash code. The hashCode method generates a unique identifier for objects based on their values. Using equals method from the Object class compares objects based on their memory addresses, but custom equals method can compare based on values. Implementing custom equals and hashCode methods ensures proper comparison and adherence to Java best practices. IDEs can automatically generate equals and hashCode methods based on selected variables, simplifying implementation. Understanding and utilizing methods from the Object class such as toString and equals is essential in Java programming. Made with HARPA AI
Christ almighty.. I've been pulling my hair trying to understand chatgpt to explain to me why I need hashcode in operator == overriding and here you go, explaining everything! Thank you!!
According to the equality rule when comparing two objects we have to override our equals and hashcode methods in such a way that the equal methods return true when both objects have same set of properties and it should have same hash codes as well.
In the first == it should return false they are two different objects with two different locations.. So equall methods returns true if the reference are same means they lie on the same location.
🎯 Key Takeaways for quick navigation:
Every class in Java implicitly extends the Object class.
The Object class provides methods like equals, hashCode, toString, etc., even if not explicitly defined in a class.
The toString method returns a string representation of the object, including the class name and hash code.
The hashCode method generates a unique identifier for objects based on their values.
Using equals method from the Object class compares objects based on their memory addresses, but custom equals method can compare based on values.
Implementing custom equals and hashCode methods ensures proper comparison and adherence to Java best practices.
IDEs can automatically generate equals and hashCode methods based on selected variables, simplifying implementation.
Understanding and utilizing methods from the Object class such as toString and equals is essential in Java programming.
Made with HARPA AI
Thanks buddy ❤
I swear your are the only channel I see that explains everything perfectly.
Christ almighty.. I've been pulling my hair trying to understand chatgpt to explain to me why I need hashcode in operator == overriding and here you go, explaining everything! Thank you!!
Sir your teaching style is too good!! It's very easy to grasp the concepts.
very well explained sir and the example of Laptop class is also very good. thanks for providing this for free❤❤
I saw yoour previous video and after seen this video I got more clearity. Thank you Sir
Thanks so much, I was really struggling. New subscriber unlocked🔓
According to the equality rule when comparing two objects we have to override our equals and hashcode methods in such a way that the equal methods return true when both objects have same set of properties and it should have same hash codes as well.
Greatest Java Tutorial ever!!
In the first == it should return false they are two different objects with two different locations.. So equall methods returns true if the reference are same means they lie on the same location.
Thank you so much!!. Only because of you I am this able to hold a good package!
Thank you sir. Amazing video as always
Super sir, i am a big fan of your work.
Thank you! I was struggling to do a toString()
This is old way now we have lombok library it's easyiest way to implement make a video for that.
Thank you
thankyou great tutorial.
Good video. Thank you for understanding this.
great explanation sir
what is hashcode for? why do we use the equals method. like why modify it?
In the toString() method, we simply used "model" and "price" but in the equals() method we had to use "this.model" and "this.price," why ?
Because we are comparing two objects, so this and that
In toStrring we are working with only one object.
great explanation. Thank you!
how can we open the predefined class file (eg: Object.class) in vs code ?
Awesome video but you didn't really explain the relationship between hashcode and equals
The Object class is the relationship between hashcode and equals because every class in Java implicitly extends the Object class.
Thank you for that explanation! So easy to follow and understand.
Hello sir I don't under stand 2 " . " here please explain
thank u so much....❤❤❤
Thank you
model model 👌
What ide you use
VS code
Why we use hash code
You just awesome
Can I get tutorial ppt
👍
this.model. equal () that please explain
"this" means the current object which calls the method
❤
Baba Nam Kevalam!
Way of explaining is not good
Why
Just this one only
If you want to understand more, you have to watch the previous video @@Psuedobot
Right😢
😂 acha mazaq hai
chomu padhane ka dhnage nahi hai
bhai apne channel ki link send krdo tb
OMG! Do you know at least what you said? This is very sad for beginners
I came to learn the generated code... But here you generated and skipped the actual use of each and every line in the code... Disappointed alien..