Java Reference
In-Depth Information
5. Compile and run the program. The following result is displayed:
6. Extra challenge: You can compute the distance to a large object, such as a rock wall,
by timing the echo. For example, if you clap your hands and time how long it takes
for you to hear the echo, then you know the total round-trip time. Dividing this value
by two yields the time it takes the sound to go one way. You can then use this value
to compute the distance to the object. Modify the preceding program so that it com-
putes the distance, assuming that the time interval is that of an echo.
Literals
In Java, literals refer to fixed values that are represented in their human-readable form. For
example, the number 100 is a literal. Literals are also commonly called constants . For the
most part, literals, and their usage, are so intuitive that they have been used in one form
or another by all the preceding sample programs. Now the time has come to explain them
formally.
Search WWH ::




Custom Search