0

I would like to know what is the recommended way to get parent class fields.

Is it better to set parent class fields protected and use directly the fields, or set fields to private and get them using getters in child classes?

Thank you very much.

hawarden_
  • 1,904
  • 5
  • 28
  • 48
  • Related https://stackoverflow.com/questions/8466790/java-conventions-use-getters-setters-within-the-class – LeoColman Nov 28 '17 at 22:44
  • 6 of one or half dozen of the other, `getters` as in any situation can be useful for debugging and facilitating extra functionality, if neither of those things are a concern then i'd just make the fields you want to expose `protected`. – George Nov 28 '17 at 22:45
  • Always please [search first](https://www.google.com/search?q=site%3Astackoverflow.com+java+parent+gettter+private+fields+or+protected) – Hovercraft Full Of Eels Nov 28 '17 at 22:47

0 Answers0