java package [base]

Foreword

Java object-oriented three properties: encapsulation, inheritance, polymorphism. This article will introduce the principle of

Package

Packaging is to achieve the kind of access control. Hide implementation details so that like users can only be accessed through pre-customized method for data, control logic can be conveniently added, unreasonable limit operational attributes
easy to modify, enhance the maintainability of the code.

Modifiers similar A package of the same class Subclass outer package Like other packages
private
default
protected
public
  • private: the same class can access this member.
  • default: the same package of class members can access this memory.
  • protected: the same package classes and subclasses of the outer package members can access this memory.
  • public: any class can access this member.
Published 33 original articles · won praise 4 · Views 580

Guess you like

Origin blog.csdn.net/weixin_43287478/article/details/104680880