Home > 类库下载 > java类库 > Those modifiers in Java language

Those modifiers in Java language

高洛峰
Release: 2016-10-20 10:48:24
Original
2226 people have browsed it

About those modifiers in the Java language

1. Some modifiers provided in java, these modifiers can modify classes, variables and methods. Common modifiers in java are: abstract (abstract), static (static) ), public (public), protected (protected), private (private), synchronized (synchronized), native (local), transient (temporary), volatile (volatile), final (not Changed)

2. The modifiers that modify the top-level class include abstract, public, and final, while static, protected, and private cannot modify the top-level class. Member methods and member variables can have multiple modifiers, while local variables can only be modified with final

Three. Accessible scopes of 4 access levels

Those modifiers in Java language

Note: Top-level classes can only be modified by default modifiers and public , cannot be modified by private and protected

4. The abstract modifier can be used to modify classes and member methods

1. Use abstract-modified classes to represent abstract classes, abstract classes cannot be instantiated

2. Use abstract-modified methods to represent abstraction Methods, abstract methods have no method body: "{}", used for subclass rewriting

3. Abstract modified classes, that is, abstract classes can have ordinary methods and abstract methods

4. Abstract classes and abstract methods Cannot be modified by the final modifier. Abstract modifier and final modifier cannot be used together

5. Final modifier

1. Final means "immutable", it can modify non-abstract classes, non-abstract member methods and variables

2. Modify with final The class cannot be inherited and has no subclasses

3. Methods modified with final cannot be overridden by methods of subclasses

4. Variables modified with final represent constants, such as (PI), so they can only be assigned once and cannot be Change

6.static modifier

1. Member variables modified with static represent static variables, which can be directly accessed through the class name

2. Member methods modified with static represent static methods, which can be accessed directly through the class name

3. Use the program modified with static to send code blocks. When the full name of Java Virtual Machine (JVM) is: Java Virtual Machine, it can locate them in the method of the runtime data area according to the class name, and it can only be run once



Related labels:
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
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template