Why does Java have so many analysis methods?
For example, the Math.max (....) method is overloaded to support different Number types . One name for all of them, because, don't print the Number type , it does the same.
Thus, parseNumberType methods are defined for each class that extends Number .
Why is it so? It would not be better if the parameterized parsing method was defined in Number (and Number of course, parameterized) like: public abstract T parse( String s );
(and implemented specifically after that in all subclasses of Number)
source to share
Number
has been around since JDK 1.0, Generics were only introduced in Java 1.5. Thus, such a general method of parsing would not be possible.
Relatively, Math.max
it only accepts primitive types that have no relationship with each other, and each primitive type must be declared separately for support.
source to share