Search code examples
javainheritanceencapsulationsuperclass

make private fields visible within inherited subclass


I am pretty new to Java, so that my question will be rather naive, I think.

For a project of mine, I decided to code in Java and I'd like making use of the encapsulation and inheritance concepts.

Staying short, I'd like to know if there is any chance to make private fields from the superclass being somehow visible from within the subclass, although still not accessible by the user?


Solution

  • It sounds like you're describing protected.

    See Controlling Access to Members of a Class from the Java tutorial.