'Why Java records do not support inheritance?
Today I hit a wall, when I was about to add new functionality to the app. I had a record with data, but I needed some extra values. Adding this to the record would not make sense, becouse for most cases they will not be used and would be nulls, so I thought inheritance, which made perfect sense in this situation. But there is a problem , becouse Java records do not support inheritance, so I ended up with rewriting record to ugly POJO class with final values and getters.
So my question is basictly - why no inheritance. I understand there is not multiple inheritance becouse it's messy and hard to control on some point, but we also have final classes that cannot be inherited, why couldn't w e have records and final records?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
