java.lang.Math is not an Abstract class. So, we should be allowed to makes its instance. When I try to do so, I get an error:
Why it is so?
Math obj = new Math();
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The constructor Math() is not visible
Math has a private constructor - hence your error message - all its methods are static so there is never a need to instantiate on, e.g.
It is not always necessary to make a class abstract to prevent it from being instanced. If you omit the constructor or give the constructor some protected access, you can also prevent it from being instanced. It is also possible for other classes to use a method to create an instance of that class without a constructor. For example:
(Just played with Regex :D) I hope this helped. ;)
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(".*");