Object about Knowledge points:
1.java is the object-oriented language, the core idea: to find the right object to do the right thing:
Method One: Customize the class, and then create the object from the custom class.
Mode two:Sun provides a lot of classes for me to use, we just need to know these classes, we can create objects through these classes.
The 2.Object class is the ultimate parent class for all classes. Any class inherits the Object class.
Object class:
common methods of the Object class:
①tostring (); Returns the string representation of the object. Returns a string that describes the object.
Question: How does toString () work? after overriding toString , when we output an object directly, we will output the format data that meets our needs.
②equals (Object obj) is used to compare memory addresses of two objects and to determine whether two objects are the same object.
③hashcode () returns the hash code value of the object ( you can interpret the hash code as the memory address of the object )/
specification in Java: generally we rewrite the equals method of a class , and we all rewrite its hashcode method .
Reason:
By default, object equals == This is a comparison of memory addresses, but if we want to compare the properties of objects, we need to rewrite equals method comparison, and hashcode java specification is overriding equals method, the hashcode method is also overridden.
3.java is open source ... . Source Code Disclosure ...
How to view the source code:
Mode one: Hold down the Ctrl key and click the source code you want to see .
Mode two: Move the cursor to the point where you need to view the code to press F3.
Why we want to view the source code:
1, look at the source code can understand how others write this technology, let us understand more in-depth.
2. absorbing Daniel's ideas.
See the source code the most taboo point: not every line of code to understand what the meaning, can see a guess what he means is enough.
Java Video Wisdom Note------Object