JAVA class modifier

Source: Internet
Author: User
Tags modifiers

The modifiers of the Java class are mainly public,default,protected,private,final,abstract,static


Where the external class uses only public,final,abstract or no modifiers, you cannot explicitly add the default

(if additional modifiers are added, eclipse will prompt illegal modifier for the class xxx; Only public, abstract & Final is permitted)


1. Access qualifiers for external classes (public, final,abstract, and default)

Public: Global access, which any class can access. A file can have only one public, and if there is public, the file name needs to be the same as the class name of the public class

Final: Prohibit inheritance

Abstract: Abstraction class

Default: In-Package access (note that you cannot explicitly add the default modifier)


2. Access qualifiers for inner classes (external classes and protected,private,static)

Protected: Only the same file, the same package, or a subclass inheriting it can use the inner class

Private: Except for its outer class and other inner classes of its outer class, it cannot access

Static: Statically internal class

JAVA class modifier

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.