In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to analyze modifier modifiers, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Modifier Summary Modifiers
The function modifier always precedes the return value type!
The variable modifier always precedes the variable type!
ClassModifier: one of
Annotation public protected private
Abstract static final strictfp
External classes: cannot be modified by protected, private, static and final
Member inner class: both are fine
Non-member inner class: none is allowed
FieldModifier: one of
Annotation public protected private
Static final transient volatile
MethodModifier: one of
Annotation public protected private
Abstract static final synchronized native strictfp
ConstructorModifier: one of
Annotation public protected private
InterfaceModifier: one of
Annotation public protected private
Abstract static strictfp
VariableModifier: one of
Annotation final
Class field method constructor interface variable
Annotation √ √
Public/protected/private √ ×
Abstract/strictfp √ × √ × √ ×
Static √ × √ ×
Final √ × × √
Transient/volatile × √ × × ×
Synchronized/native × × √ × × ×
Annotation
All of the above is fine.
Public/protected/private
Permission modifier, except variable can be-> frequently tested.
Abstract/strictfp
Class/interface/method
Static
Except for constructor and variable, you can take the regular exam.
Final
Except for constructor and interface.
Transient/volatile
Can only modify field
Synchronized/native
Can only modify method
Final and abstract are in conflict.
/ *
Summary of access permissions for members and constructors between packages:
Public protected has no modifier private
Ok ok ok ok in the same class
Ok ok ok in the same package
Different package * subclass ok ok
Ok in different packages
Prerequisite for different package member access: the accessed class must be public, and the accessed member must be public
Subclasses in different packages can also directly access members and constructors of protected in the parent class.
There are two levels of permission restrictions for different package access:
The first layer is the permission restriction of the class, and the permission of the class can be public/ unauthorized modifier.
The second layer is the permission restriction of members. The permissions of members can be public/protected/ No permission modifier / private and so on.
Access must be allowed by the permissions of the class before considering whether the permissions of members are allowed to access!
In actual programming, the classes accessed are generally of different packages:
The class is public and the constructor is public
Allow objects to be created by classes with different packages; otherwise, objects are not allowed to be created by classes with different packages
The class is public and the constructor is protected
Only classes with different packages are allowed to inherit (designed to be inherited, and objects are not allowed to be created by classes with different packages)
The class is public and the constructor is private (usually final)
It is not allowed to create objects (including the classes in this package). In this case, the public method is generally provided to get the objects of the class.
In different packages, the role of protected is to restrict members and constructors to be accessed by subclasses
In the same package, protected has no effect when modifying member variables and constructors, but only overrides member functions.
, /
On how to analyze the modifier modifier to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.