+ 1

Can someone provide a good explanation of why is not necessary to create an object of the Class Math, please ?

In the description it says that it is only necessary to call the Class and the method.. like Math.max (x,y)

19th Apr 2017, 8:57 PM
Álvaro Gómez Uría
Álvaro Gómez Uría - avatar
4 Respuestas
+ 5
actually note that the Math class's constructor is actually declared private, therefore you cannot even make a Math object even if you wanted to
19th Apr 2017, 9:07 PM
Edward
+ 4
I found the answer some slides after. It because all the methods are defined as static.
19th Apr 2017, 9:02 PM
Álvaro Gómez Uría
Álvaro Gómez Uría - avatar
+ 2
math is a static class then you can call it directly , when you hse static class the compiler create instance of this class it is instance shared between classes , read more about 1_ static class 2_ singleton design pattern
21st Apr 2017, 12:42 PM
Eng Hazymeh
Eng Hazymeh - avatar