java - if there are 3 classes A,B,C a and b are in same package c is in different package, to access fields of A why C must be child of A but not b? -


there class , class b, class c.

if class , b in same package not c; access fields of class ; c must child of a.this rule not class b may or may not child of access fields .why?

declare fields of class a , class b public. default visibility when don't put public, private etc. fields visible classes within same package.

from java docs:

if class has no modifier (the default, known package-private), visible within own package (packages named groups of related classes — learn them in later lesson.)

http://docs.oracle.com/javase/tutorial/java/javaoo/accesscontrol.html


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -