为什么没有像c++那样事先声明 Math的对象?
难道Math是静态类?
------解决方案--------------------
不是 因为sin是静态方法 你可以试一下。 新建一个类Test, 然后在类Test里面写个静态方法a,
那么你可以在别的类中通过test.a()调用a方法, Math.sin同上
------解决方案--------------------
不是静态类,但
- Java code
/** * Returns the trigonometric sine of an angle. Special cases: * <ul><li>If the argument is NaN or an infinity, then the * result is NaN. * <li>If the argument is zero, then the result is a zero with the * same sign as the argument.</ul> * * <p>The computed result must be within 1 ulp of the exact result. * Results must be semi-monotonic. * * @param a an angle, in radians. * @return the sine of the argument. */ public static double sin(double a) { return StrictMath.sin(a); // default impl. delegates to StrictMath }