Explore those modifiers in the Java language _java

Source: Internet
Author: User
Tags modifier modifiers volatile

I. Some of the modifiers provided in Java that can modify classes, variables, and methods, which are common in Java: abstract (abstract), static (static), public (common), protected (protected), Private ( private), synchronized (synchronous), native (local), transient (temporary), volatile (volatile), final (immutable)

Two. modifier top-level class modifiers include abstract, public, and final, while static, protected, and private cannot modify the top-level class. Member methods and member variables can have several modifiers, while local variables are only final decorated

Three. Accessibility to 4 levels of access

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

Four. The abstract modifier can be used to modify class and Member methods

1. A class that is abstract decorated is an abstraction class, and an abstract class cannot be instantiated

2. An abstract method is represented by an abstraction method, which has no method body: "{}", which is used for subclasses to override

3.abstract decorated classes, that is, abstract classes can have common methods and abstract methods

4. Abstract classes and abstract methods cannot be decorated with the final modifier. The abstract modifier and the final modifier cannot be used

Five. Final modifier

1.final is the meaning of "immutable", which can be decorated with non-abstract, non-abstract member methods, and variables

2. Classes with final modifications cannot be inherited, no subclasses

3. The final modified method cannot be overridden by a quilt class

4. The final modified variable represents a constant, such as (PI), so it can only be assigned once and cannot be changed

Six. Static modifier

1. member variables decorated with static represent static variables that can be accessed directly through the class name

2. The member method, which is decorated with static, represents a static method that can be accessed directly through the class name

3. Code blocks with static modifications, when the full name of the Java Virtual Machine (JVM) is: Java machine can navigate to them based on the class name in the method of the Run-time data area, and can only run once

The above is a small set to introduce the Java language in those modifiers, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.