Java Fundamentals Review-5 (Reference data type)

Source: Internet
Author: User

1. What are the types of reference data? Test analysis.

Answer: There are two kinds.

the first kind, Java provides us with good classes, such as the scanner class, the random class, etc., these existing classes contain a lot of methods and properties that we can use.

Second, we create our own classes, according to the definition of the class, you can include multiple methods and properties in the class for us to use.

2. The definition format of the class

For:

Create A Java file that is the same as the class name

public class class name {

Data Type Property name 1;

Data Type Property name 2;

...

}

3. What is the usage format of the class?

For:

Guide Package: We put all the classes under the same folder and can avoid the guide package.

Create object: Data type variable name = new data type ();

Call Method: currently we define a custom class that does not involve methods, just attributes (the method part of the custom class is explained in the object-oriented section)

Access attribute: variable name . Properties ( this is the current way, and later the method is called to replace the direct access to the way to complete the access to the property.) )

Customization Type considerations:

through the variable name. Property names can be used to manipulate attributes;

Like an array of reference types, a variable of a custom type referencing a type, directly outputting a variable, results in an object address value, which can be simply explained by a memory graph. The memory graph is as follows:

Java Fundamentals Review-5 (Reference data type)

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.