java - how to declare a method in parent abstract class so that it can be accessed by children? -


in java, have abstract class method implemented (not abstract) want accessible other classes extend it, not else in package..

i think not possible, because private keeps private, public , protected expose much..

how approach problem? reimplementing same method in extended classes out of discussion.. there way access parent methods?

thanks!

use protected , make package contains abstract class , it's subclasses. don't put other classes in package shouldn't have access protected methods.

if concern else might create new class in package , start accessing protected methods, there isn't language construct prevent that. have either trust other developers or have stringent peer review process.


Comments