+ 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)
4 ответов
+ 7
answer is here
http://stackoverflow.com/questions/576228/why-are-the-methods-of-the-math-class-static
and some light reading regarding static methods
http://stackoverflow.com/questions/2671496/java-when-to-use-static-methods
http://introcs.cs.princeton.edu/java/21function/
+ 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
+ 4
I found the answer some slides after. It because all the methods are defined as static.
+ 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