Some summary.

Source: Internet
Author: User

Summary of the 1.static.

  1. The static method can be called directly with the class name, not as an instance of Mr.
  2. The main method is the static method, because whenever a class defines the main method, his main method is called before the class is constructed as a function. That is, it must be called before the instance is created, so it must be the static method.
  3. The static method is a class method
  4. If you want the method to be called by other classes and methods, declare static.

2.public and private

  1. Public-qualified methods and data fields can be used in the largest range and can be used in other packages.
  2. Next is the method and data field without any prefix, which can be used in different classes within the package.
  3. The smallest of the private methods and data fields, which can only be used in its own class.
  4. A bunch of data fields have to be prefixed with private to avoid any arbitrary modification of the data field. If you want to modify the data field, you can create some methods in the class to modify, you can add some criteria before modifying the condition to be satisfied with the situation. (because it is possible to modify the private data field in the Class) This is called the encapsulation of the data field (refers to the private decoration)

Some summary.

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.