Chapter 8
From APIs to Programs
8.1 The Making of a Program
class trivial{
public static void main(String[] args){}
}
8.2 Assigning Meaning to Programs
- Programs are processors of information
- The information provided to a program is said to be its input
- The information produced by a program is said to be its output
- The meaning of a program is the input-output relationship defined by the program
- API’s define the structural spine for programs
- With well chosen names, and informative comments, APIs show the intended meaning of programs.
- The actual meaning of a program is realized through code introduced to the bodies of its methods and constructors.
class helloWorld{
public static void main(String[] args){
System.out.println("Hello World!");
} }
The instruction ‘System.out.println("string")’ is among the simplest available for outputing text.
8.3 General Rules
8.4 Code Comments
- The API comments /** ... */ are extract by the javadoc utility into the documentation
- Comments of the form /* ... */ are ignored by javadoc and the other utilities. They are for local use within the
code by the programmers.
- A double slash // designates the remainder of the line to be a comment.
Exercises
8.5 Assignment #9: Simple Programming
Due: Fr, Apr 25, midnight
Write a program which outputs the following code.
Ring around the rosie,
Pocket full of posie,
Ashes, ashes,
We all fall down.
Round the ring of roses,
Pots full of posies,
The one who stoops last,
Shall tell whom she loves best.
Assume ‘lab9’ for the submit program, and the name roses.java for the file containing the program..
Note: Files that fail to compile, and execute when applicable, will not be examined. They will be awarded a grade
of 0 points.