posted 23 years ago
Hi Aparna!
Here is a small research program (SRP):
Confusing, no?
There are a few overloaded max methods in Math class, but we are interested in two:
float max (float, float) and
double max (double, double)
When we call max method as Math.max (float, double) float parameter is promoted to double and max (double, double) method is called (double parameter cannot be automatically converted to float, that�s why max (float, float) cannot be called). Type of return parameter is double, that�s why line 2 is printed. When we compare Float.POSITIVE_INFINITY with Double.POSITIVE_INFINITY, float is promoted to double, that�s why first line is printed.
Or more explicitely
To have better idea how INFINITY is represented:
Hope this help a little...