Sealed class in Java
In Java, to prevent the inheritance of a certain class, we will use the final keyword to declare that class. Examples are as follows:
1 2 3 4 5 6 7 8 9 10 11 |
package com.huongdanjava.javaexample; public final class JavaExample { public static void main(String[] args) { } class Test extends JavaExample { } } |
Class Test will not be able to inherit JavaExample class because this JavaExample class is declared with final: A need… Read More