Java Base access modifier protected

Source: Internet
Author: User

Java access modifier Protected keywords I am puzzled, many people on the internet, the self-annotation of the industry has still not eliminated my understanding of this keyword.

My doubts have the following points:

1: Add protected keyword of the original intention, that is to say: this "protected" principle is what??

2: In the Think in Java, the definition of protected is incorrect.

What is the role of 3:protected?

4: Inheritance is involved.

In the Java programming Mind: By reading, my understanding is:

There are two scenarios for inheriting classes that have protected access modifiers:

(1) Inheritance of different packages.

The book says: In a new package, the class inherits the class from the original package, and can only access the public decorated members in the original class.

(2) Inheritance in the same package:

The class object in the package can access the member variables or methods that are protected decorated





This article is from the "Night" blog, make sure to keep this source http://8991120.blog.51cto.com/8981120/1662770

Java Base access modifier protected

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.