Home > Java > javaTutorial > What are java modifiers?

What are java modifiers?

藏色散人
Release: 2019-05-22 14:34:06
Original
11296 people have browsed it

Java modifiers are used to modify the access restrictions or type restrictions of classes, variables, and methods. They mainly include the following: public, protected, private, default, static, final, abstract, transient, and volatile. The first four are is the access qualification modifier, and the last few are type qualification modifiers.

What are java modifiers?

The Java language provides many modifiers, which are mainly divided into the following two categories:

Access modifiers

Non-access modifier

java modifier is used to define classes, methods or variables, usually placed at the front of the statement.

Access control modifier

In Java, you can use access control modifiers to protect access to classes, variables, methods, and constructors. Java supports 4 different access rights.

default (i.e. default, write nothing): Visible in 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, methods

protected: Visible to classes and all subclasses in the same package. Use objects: variables, methods. Note: Classes (external classes) cannot be modified.

The above is the detailed content of What are java modifiers?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template