Java Basic Note 8

Source: Internet
Author: User

Object class

The object class is the parent class for all classes. If a class does not appear to inherit from a parent class, then the class inherits object.

Class Object is the root class of a class hierarchy. Each class uses Object as a superclass.
All objects, including arrays, implement methods of this class.
The 1.toString method returns the object information.
2.equals method. The default comparison reference address.
equals of the object class for any non-null reference value x and Y, when and only if X and Y refer to the same object,
This method returns True (x = = Y has a value of true).
If any two objects of a class, if you want to compare the contents of an object, you must override the Equals method in this class.

Packing class

Encapsulates a basic data type into a class.
 Char--->character (character)
Int-->integer
Long-->long
Byte-->byte
Short-->short
Float-->float
Double->double
Boolean-->boolean

Boxing: Turns the basic type into a wrapper type.
Unpacking: Change the package type to a basic type.

After jdk1.5
Automatic Boxing: Automatically turns the base type into a wrapper type.
Automatic unpacking: Automatically turns the package type into a basic type

Application of Packaging class

Example: Integer parseint (String) converts a numeric string into an integer

Java Basic Note 8

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.