<< Chapter < Page | Chapter >> Page > |
Revised: Sun Mar 27 18:57:37 CDT 2016
This Page is included in the following Books:
The purpose of this module is to present the first complete Java program of the collection that previews the most commonforms of the three pillars of procedural programming:
The program also illustrates
As mentioned above, this is simply a preview. Detailed discussions of these topics will be presented in future modules.
I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the Figuresand Listings while you are reading about them.
Assuming that the Java Development Kit (JDK) is properly installed on your computer (see Jb0110: Java OOP: Programming Fundamentals, Getting Started ), do the following to compile and run this program.
1. Copy the text from Listing 1 into a text file named FirstProgram.java and store the file in a folder on your disk.
2. Open a command-line window in the folder containing the file.
3. Type the following command at the prompt to compile the program:
javac FirstProgram.java
4. Type the following command at the prompt to run the program:
java FirstProgram
Any text in the program code that begins with // is a comment. The compiler will ignore everything from the // to the end of the line.
Comments were inserted into the program code to explain the code.
The compiler also ignores blank lines.
Note that this program was designed to illustrate the concepts while being as non-cryptic as possible.
The program should display the text shown in Figure 1 on the screen except that the time will be different each timeyou run the program.
Figure 1 . Program output. |
---|
value in = 5
Odd time = 1353849164875countA = 0
countA = 1countA = 2
countB = 0countB = 1
countB = 2value out = 10 |
I encourage you to copy the code from Listing 1 . Compile the code and execute it. Experiment with the code,making changes, and observing the results of your changes. Make certain that you can explain why your changes behave as they do.
This section contains a variety of miscellaneous information.
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?