Access control permissions and naming conventions

Source: Internet
Author: User
Purpose of this section: Specific: Access control permissions: Previously learned three access control permissions: Private, default, public private: You can define methods, properties, defined methods and properties that cannot be seen by the outside of a class default: You can access it in any class in this package Protected: protection, different packages non-subclasses cannot access public: common, accessible, and not subject to any restrictions summary: When a class is generated, the Private keyword is used in order to ensure that the contents of the class are not seen directly from the outside. If two relational classes are troublesome to have access to each other, they can only be accessed and set using Getter/setter, so the inner class is used to reduce the hassle of accessing private properties, but the inner class itself changes the structure of the program itself. In order to make the contents of a class easy to see, the use of the concept of inheritance, but in the inheritance of private properties can not be seen in the quilt, so at this time, in order to facilitate the operation of subclasses, you can use the protect to encapsulate the properties, so that the external cannot see directly After the inheritance, since there is a father-son relationship, so you can use an upward-downward transition to complete polymorphism, but there is not much direct inheritance between classes and classes in development, often inheriting abstract classes or implementing interfaces, which can be accomplished when several small operations require decoupling. Since there are inner classes, If a subclass of an interface or abstract class is used only once, it can be defined as an anonymous inner class. A class with no packages in development is absolutely nonexistent encapsulation---> Inheritance---> Polymorphism

Naming conventions: Summarizing: A few keywords to learn access rights: Private, default, protect, public naming conventions





















































































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.