|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
You use an instance of one of theNumberclasses-Byte,Double,Float,Integer,Long, andShort-to contain a number of primitive type. You can also useBigIntegerandBigDecimalfor arbitrary-precision numbers.The
Numberclasses include class methods and constants, which are useful in a variety of ways. TheMIN_VALUEandMAX_VALUEconstants contain the smallest and largest values that can be contained by an object of that type. ThebyteValue,shortValue, and similar methods convert one numeric type to another. ThevalueOfmethod converts a string to a number, and thetoStringmethod converts a number to a string.To format a number to display to an end user, you use the
NumberFormatclass in thejava.textpackage. When usingNumberFormat, you can get a default format for decimal numbers, percentages, or currency. Or, you can design a custom format using patterns.The
Mathclass contains a variety of class methods for performing mathematical functions. This class includes the trigonometric functions, such as computing sine, cosine, and so on.Mathalso includes functions for logarithm calculations, as well as basic arithmetic functions, such as rounding. Finally,Mathcontains a method,random, for generating random numbers.
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.