September 2011
Beginner
650 pages
15h 47m
English
In the preceding program, a variable of type int was used. However, a variable of type int can hold only whole numbers. Thus, it cannot be used when a fractional component is required. For example, an int variable can hold the value 18, but not the value 18.3. Fortunately, int is only one of several data types defined by Java. To allow numbers with fractional components, Java defines two floating-point types: float and double, which represent single- and double-precision values, respectively. Of the two, double is the most commonly used.
To declare a variable of type double, use a statement similar to that shown here:
![]()
Here, ...
Read now
Unlock full access