Java Reference
In-Depth Information
Where more than one type of argument is noted in the table, there are actually several methods, one for
each type of argument, but all have the same name. You will see how this is possible in Java implementing
class methods, covered in Chapter 5.
Several methods implement mathematical functions in the Math class. You'll probably be surprised at
how often you find uses for some of these. The mathematical methods you have available are shown in Table
2-5 :
TABLE 2-5 : Math Class Mathematical Functions
I have not discussed all the methods in the Math class here, just the most commonly used ones. You may
want to explore the JDK documentation to get a feeling for the rest.
You can try out a sample of the contents of the Math class in an example to make sure you know how
they are used.
TRY IT OUT: The Math Class
You are planning a new circular pond in which you want to keep fish. Your local aquatics supplier tells
you that they can stock the pond with fish at the rate of 2 inches of fish length per square foot of pond
surface area. Your problem is to calculate the radius of the pond that will accommodate 20 fish averaging
10 inches in length. The solution, of course, is to write a Java program — what else? The following pro-
gram calculates the radius of a pond in feet and inches that can provide a home for the number of fish
you would like to keep:
 
 
Search WWH ::




Custom Search