No - private
fields can only be directly accessed within the class in which they are declared. You could make the field protected
, however, which would allow you to access it from subclasses. The table below is a handy reference:
Access permitted by each moodier:
Modifier Class Package Subclass World
----------------------------------------------
public Y Y Y Y
protected Y Y Y N
no modifier Y Y N N
private Y N N N
[source]
Of course you can also write a public
(or protected
!) getter method which would just return the value of your field, and use this method in the subclass instead of the actual field itself.
Just as an aside, it is convention to write variable names in camelCase in Java, i.e. maxSize
.