Chapter     7

Exploring the Basic APIs, Part 1

The standard class library’s java.lang and other packages provide many basic APIs that can benefit your Android apps. For example, you can perform mathematics operations and manipulate strings.

Exploring Math

The java.lang.Math class declares double constants E and PI that represent the natural logarithm base value (2.71828...) and the ratio of a circle’s circumference to its diameter (3.14159...). E is initialized to 2.718281828459045 and PI is initialized to 3.141592653589793. Math also declares class methods that perform various mathematics operations. Table 7-1 describes many of these methods.

Table 7-1. Math Methods

Method

Description

double abs(double d)

Returns the absolute value ...

Get Learn Java for Android Development, Third 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.