How can we restrict inheritance for a class?
1. Use final.
2. Use private constructors.
3. Use a comment: // do not inherit.
4. Use a javadoc comment.
5. Make every method final, so people can't override them.
6. Use a runtime check in the class constructor: if (this. getClass() != MyClass. class) { throw new RuntimeException("Subclasses not allowed"); }