Eugene Paitoo3,531 Points
A little help needed
I'm totally lost right from the beginning to the end of this video. i didn't get the whole video and please a little help will be appreciated.
Thanks very much! :)
Hi there! I think the way that the concept is explained in the video is a bit confusing.
A couple of the main takeaways are that: It is generally better practice to use the .equals method rather than double equal signs (==) to check for equality. The reason for this is because in java the == does NOT check for equality when dealing with objects, only with primitives (integers, etc). All objects inherent from a generic object (known as "object"), meaning all objects can use the .equals method by default.
Even objects that you make yourself inherit from the generic object. There are many methods that objects inherit from the generic object, but for right now we are only concerned about the .equals method.
If you were to use:
object1 == object2
This checks that the objects reference the same location in memory.. This is most likely not what we are looking for (and will return false unless they are the SAME object) if we are trying to compare some value. To check for equality we use:
I hope this helps a bit, these are some main points the video was trying to convey, if you have any other questions don't hesitate to ask! Also don't feel discouraged if you don't immediately understand it, I know it can be confusing and digesting it over a couple days really helps! Take care and happy coding :)