O'Reilly logo

The Java™ Tutorial Fourth Edition: A Short Course on the Basics by Mark Hoeber, Tom Risser, Isaac Rabinovitch, Jacob Royal, Scott Hommel, Sharon Zakhour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Numbers and Strings

Numbers

This chapter begins with a discussion of the Number[1] class in the java.lang package, its subclasses, and the situations where you would use instantiations of these classes rather than the primitive number types.

This section also presents the PrintStream[2] and DecimalFormat[3] classes, which provide methods for writing formatted numerical output.

Finally, the Math[4] class in java.lang is discussed. It contains mathematical functions to complement the operators built into the language. This class has methods for the trigonometric functions, exponential functions, and so forth.

The Numbers Classes

When working with numbers, most of the time you use the primitive types in your code. For example:

int i = 500; float ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required