Java Study Notes day08_day09 _ Object Instantiation _ private_this,

Source: Internet
Author: User

Java Study Notes day08_day09 _ Object Instantiation _ private_this,

1. Classes and objects

Class is a template.

Object Instantiation is to use the new keyword to create an actual object based on the template class.

 

2. Define classes and create objects

Class Definition Format:

Public class name {// attribute (variable) data type variable name;... // method modifier return value type method name (parameter ){}}

 

Format of the created object:

Class Name object name = new Class Name ();

 

 

3. encapsulate private

Encapsulation: hides the Implementation Details of Object Attributes and methods, and only provides some public access methods.

Private: private modified members can only be accessed in the current class, but cannot be accessed directly in other classes.

 

4. this keyword

This keyword is a reference to this class object. this is used in the method. Which object calls this method, then this indicates that the object that calls this method references.

This function is used to distinguish member variables with the same name from local variables (this. member variables)

 

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.