The role of classes contained in Java

Source: Internet
Author: User

When we write Java programs, we sometimes see a situation like this.

For example:

Class b{}

Class a{}

New A (b)//In this statement, Class A contains class B meaning that any data of Class B can be invoked directly using Class B object class

Here I use the human body to make a metaphor

For example, there is a human class person{}

Have a header class head{}

There is a body class body{}

There is a lower extremity class foot{}

Here, let's create a header class.

Head H =new head ();

A Body class

Body b=new body ();

A lower extremity class

Foot F =new foot ();

Finally, create a human object.

Person p = new person (h,b,f);

In person you can arbitrarily invoke any property of any property of the body by any attribute of the head, so that you can divide this man more carefully and also get you to be more flexible with this person's object

Don't know the right to say hey!

The role of classes contained in Java

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.