This was super helpful for me. I was getting confused on how to implement an Override equals method from scratch and this just cleared up all of my questions. Thank you!
Hi, I'm taking a java course at my University. This video has cleared things up quite a bit. I just have one question though, I am having trouble understanding why you would need to cast the object into a (Student)? What is the reason for this?
Hi, it's because the parameter is Object, and in order for java to know that the type of that object is Student, then you cast it to covert it to a Student object. This allows you to call Student methods
@@Appficial Couldn't we use in our if statement the operator instanceof, for example, in each if (or a bigger if in case we use && for each condition) can't we put obj instanceof Student?
Just to make sure I'm not missing something. Since the StudentID field is private, don't you need a public getter to get it from the argument object instead of dotting it? However it works for you. EDIT: Nevermind, it's because they share the same class. I was thinking that encapsulation worked cross object too but no.
@@Appficial I'm actually self studying for the APCSA exam. Inheritance was kind of hard and confusing(too theoretical) but your videos really align to the concepts I found hard. Have a great day!
If an equals method is in a Student class, then it's expected to only pass Student objects to it. Its bad programming to pass a nonstudent object to it, so my implementation is not wrong, but your method call is actually wrong.
This was super helpful for me. I was getting confused on how to implement an Override equals method from scratch and this just cleared up all of my questions. Thank you!
Glad it helped!
Please SUBSCRIBE! More programming videos coming soon! ✌️
Thank you, I wish professors explained it this simple.
Thanks I actually am a professor 👍
thank you so match (يسعدلي الشارب)
Hi, I'm taking a java course at my University. This video has cleared things up quite a bit. I just have one question though, I am having trouble understanding why you would need to cast the object into a (Student)? What is the reason for this?
Hi, it's because the parameter is Object, and in order for java to know that the type of that object is Student, then you cast it to covert it to a Student object. This allows you to call Student methods
@@Appficial Thank you for the explanation. My professor has not gone over the Object keyword yet, so this cleared up a lot of confusion.
@@alexcondon1116 you're welcome. Don't forget to subscribe and tell your classmates about appficial 👍
@@Appficial Couldn't we use in our if statement the operator instanceof, for example, in each if (or a bigger if in case we use && for each condition) can't we put obj instanceof Student?
@@jorge5208 yea that's another way to do it
LOve your demonstration
Just to make sure I'm not missing something. Since the StudentID field is private, don't you need a public getter to get it from the argument object instead of dotting it? However it works for you.
EDIT: Nevermind, it's because they share the same class. I was thinking that encapsulation worked cross object too but no.
thats because private is a class level.
great explanation and easy to follow.
Thanks Luis
Hi, how come in the if statement we used s.getName() [s.getName().equals(this.getName())] instead of just s.name [s.name.equals(this.name)]
If you are in the class where you declared name, then no need to call getName() since you have direct access to that variable
@@Appficial thank you!
super helpful! thanks
These videos are amazing!!! Thank you so much!
Thanks!
@@Appficial I'm actually self studying for the APCSA exam. Inheritance was kind of hard and confusing(too theoretical) but your videos really align to the concepts I found hard. Have a great day!
@@supernovic99 good luck on the exam. Glad my videos help!
Thank yuo professoer
Thanks a lot. Very helpful
how to find earlier class link
It was helpful. thank you sir.
Thanks!!!!!
I thought we used to equals method just because we compare the content instead of the reference.
It compares content for String but for other objects it compares reference unless you override the method to compare content
your implementation is wrong if we pass a value which is not an instance of Student we get an error, same if we pass null.
If an equals method is in a Student class, then it's expected to only pass Student objects to it. Its bad programming to pass a nonstudent object to it, so my implementation is not wrong, but your method call is actually wrong.
Danke
ANGRIFF
Nin thika
ааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааа