The Math class

 

In Java, can be represented as (click here)
 
(-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a)

 

 

static double exp(double a)
          Returns Euler's number e raised to the power of a double value.

static double log(double a)
          Returns the natural logarithm (base e) of a double value.

static double sin(double a)
          Returns the trigonometric sine of an angle.

static double cos(double a)
          Returns the trigonometric cosine of an angle.

static double tan(double a)
          Returns the trigonometric tangent of an angle.

static long round(double a)
          Returns the closest long to the argument.

static double min(double a, double b)
          Returns the smaller of two double values.
static float min(float a, float b)
          Returns the smaller of two float values.
static int min(int a, int b)
          Returns the smaller of two int values.
static long min(long a, long b)
          Returns the smaller of two long values.

static double max(double a, double b)
          Returns the greater of two double values.
static float
max(float a, float b)
          Returns the greater of two float values.
static int
max(int a, int b)
          Returns the greater of two int values.
static long
max(long a, long b)
          Returns the greater of two long values.

Calling Static Methods

  • A static method does not operate on an object double x = 4;
    double root = x.sqrt(); // Error

  • Static methods are defined inside classes  

  • Naming convention: Classes start with an uppercase letter; objects start with a lowercase letter

Math
System.out