Java Video Wisdom Note------Object

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.