2017/05/16 Java Basics Essay

Source: Internet
Author: User

1, the difference between a member variable and a local variable

1) different locations in memory

Member variables: In heap memory (member variables belong to object, object into heap memory)

Local variables: In-stack memory (local variables belong to method, method into stack memory)

2) different initialization values

Member variable: has default initialization value

Local variables: There is no default initialization value, which must be defined and assigned before it can be called.

2. Encapsulation

Private: The modified member can only be accessed in this class

    

Class Ensultation {  new person (). age=10; not this type of error }class person{  private int age;        }

Private is simply a form of encapsulation that is not available under the same package (using the default modifier).

3. The construction method also has a return statement, the format is return;

4. Overloading of methods

Constructing method overloads

Overloaded: Method name is the same, regardless of return value type (construction method no return value), see only parameter list

5. If you manually give the construction method, the system will no longer provide a default parameterless construction method

Note: If you want to use a non-parametric construct at this time, you must give it yourself manually, and suggest that you always give the non-parametric structure yourself.

2017/05/16 Java Basics Essay

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.