The JavaTM Tutorial

| 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` class in `java.lang` and its subclasses. In particular, this section talks about why you might need these 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` and `DecimalFormat` classes in `java.text` to format them. Also, the `Math` class in `java.lang` contains class methods that perform mathematical functions beyond those provided by the language. This class has methods for the trigonometric functions, exponential functions, and so on.

> Number classes:

> - `Number`
> - `Byte`
> - `Double`
> - `Float`
> - `Integer`
> - `Long`
> - `Short`
> - `BigDecimal`
> - `BigInteger`
> Wrappers for other data types (for completeness):
> - `Boolean`
> - `Character`
> - `Void`
> Beyond basic arithmetic:
> - `Math`

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form

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