The Java language provides many modifiers, which are mainly divided into the following two categories:
Access modifiers (recommended Study: java course)
Non-access modifier
Modifier is used to modify a class, method or variable, usually placed The beginning of the statement. We use the following example to illustrate:
public class ClassName { // ... } private boolean myFlag; static final double weeks = 9.5; protected static final int BOXWIDTH = 42; public static void main(String[] arguments) { // 方法体 }
Access control modifier
##In Java, you can use access control modifiers to protect classes, Access to variables, methods and constructors. Java supports 4 different access rights.
default (i.e. default, write nothing): Visible within the same package, no modifiers are used. Use objects: classes, interfaces, variables, methods. private : Visible within the same class. Use objects: variables, methods. Note: Classes (external classes) cannot be modified public: visible to all classes. Used objects: classes, interfaces, variables, methodsprotected: Visible to classes and all subclasses in the same package. Use objects: variables, methods. Note: Classes (external classes) cannot be modified.Non-access modifier
In order to achieve some other functions, Java also provides many non-access modifiers.
static modifier, used to modify class methods and class variables. The final modifier is used to modify classes, methods and variables. Classes modified by final cannot be inherited, modified methods cannot be redefined by inherited classes, and modified variables are constants and cannot be modified. abstract modifier, used to create abstract classes and abstract methods. synchronized and volatile modifiers are mainly used for thread programming.The above is the detailed content of What do java modifiers modify?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft