Java Reference
In-Depth Information
3. Compile the program using the following command line:
4. Run the program using this command:
You will see this output:
5. As it stands, this program converts 10 gallons to liters. However, by changing the
value assigned to gallons , you can have the program convert a different number of
gallons into its equivalent number of liters.
Two Control Statements
Inside a method, execution proceeds from one statement to the next, top to bottom.
However, it is possible to alter this flow through the use of the various program control
statements supported by Java. Although we will look closely at control statements later,
two are briefly introduced here because we will be using them to write sample programs.
The if Statement
Search WWH ::




Custom Search