The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Learning the Java Language
Lesson: Object Basics and Simple Data Objects

Numbers

This section begins with a discussion of the Number (in the API reference documentation) class in java.lang (in the API reference documentation) and its subclasses. In particular, this section talks about the rare situations that you might use these classes instead of the primitive number classes, points out the common methods and class variables they have in common, and shows you how to convert instances to strings.

Additionally, this section talks about other classes you might need to work with numbers. For instance, if you need to display a number in a particular format, you can use the NumberFormat (in the API reference documentation) and DecimalFormat (in the API reference documentation) classes in java.text to format them. Also, the format facility of PrintStream (in the API reference documentation) and PrintWriter (in the API reference documentation) provides convenient methods for writing a formatted string to an output stream.

Finally, the Math (in the API reference documentation) class in java.lang contains mathematical functions to complement the operators built-in to the language. This class has methods for the trigonometric functions, exponential functions, and so on.


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.