Java: how to implement private abstract methods?

You can’t have private abstract methods in Java.

When a method is private, the sub classes can’t access it, hence they can’t override it.

If you want a similar behavior you’ll need protected abstract method.

It is a compile-time error if a method declaration that contains the keyword abstract also contains any one of the keywords private, static, final, native, strictfp, or synchronized.

And

It would be impossible for a subclass to implement a private abstract method, because private methods are not inherited by subclasses; therefore such a method could never be used.


Resources :

  • JLS – 8.4.3. Method Modifiers
  • JLS – 8.4.3.1. abstract Methods

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)