When we want to close a class to inheritance we are declaring class with final,
final class Myclass {}
but when we declare the constructor private it will be the same effect,
class Myclass {
private Myclass() {}
}
But is it really the same? Is there any difference for optimization of code or readability of code? And which classes has to close to inheritance,
- immutable class maybe
- every method and member variable declared static of class
But for second option java.util.Arrays hasn't been declared with final even if all methods of Arrays are declared static.