APIs

public class Math

double

abs(double a)

absolute value of a

double

max(double a, double b)

maximum of a and b

double

min(double a, double b)

minimum of a and b

Note 1: abs(), max(), and min() are defined also for int, long, and float.

double

sin(double theta)

sine of theta

double

cos(double theta)

cosine of theta

double

tan(double theta)

tangent of theta

Note 2: Angles are expressed in radians. Use toDegrees() and toRadians() to convert. Note 3: Use asin(), acos(), and atan() for inverse functions.

double

exp(double a)

exponential (ea)

double

log(double a)

natural log (loge a, or ln a)

double

pow(double a, double b)

raise a to the bth power (ab)

long

round(double a)

round a to the nearest integer

double

random() ...

Get Introduction to Programming in Java: An Interdisciplinary Approach, second edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.