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?
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... eg :
public class Editor {
private final EditorLibrary editor;
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.