Java Reference
In-Depth Information
first subclass then it could manipulate them in a way that would break
the first subclass's contractand this should not be permissible.
Protected static members can be accessed in any extended class. If head
were a static field, any method (static or not) in PriorityQueue could ac-
cess it. This is allowed because a subclass can't modify the contract of
its static members because it can only hide them, not override them-
hence, there is no danger of another class violating that contract.
Members declared protected are also available to any code within the
package of the class. If these different queue classes were in the same
package, they could access one another's head and tail fields, as could
any unrelated type in that package. Classes in the same package are
assumed to be fairly trustworthy and not to violate each other's con-
tractssee Chapter 18 . In the list "private, package, protected, public,"
each access level adds to the kinds of code to which a member is ac-
cessible.
 
Search WWH ::




Custom Search