How can Java class extend Kotlin library?
I understand what all kotlin classes are final.
I have library and I need to override some methods. But then I extend library, I'm getting error
public class Editor extends EditorLibrary //error Cannot inherit from final
Any chances to extend kotlin final class, because I can't change it to open?
CodePudding user response:
If you have control over the library you can open the class for extension using the open
keyword, otherwise, as you've mentioned, the class was not built for extensions...
open EditorLibrary(...) {
}
In such case you might consider using composition over inheritance... e.g. :
public class Editor {
private final EditorLibrary editor;
...
}