|
Is the pattern in the int value 221 the same pattern as in the float value 221.0? A good answer might be:No. Integer and floating point types use bits in fundamentally different ways. | ||
Converting a String to a DoubleHere is a program that converts a String of characters into primitive type double. In this program, the characters that are converted are contained in a String literal. (We will do IO later on). The program will not run under versions of Java earlier than 1.2 because they do not have the parseDouble() method.
The reserved word final means that the value inside the variable charData will not change. This program is recommended for "copy-paste-and-run." Running the program writes the following to the screen:
The details of how this program works are on the next page. | ||
QUESTION 2:Would the program would work if the declaration of charData were changed to:
Click Here after you have answered the question
|