Java Reference
In-Depth Information
Chapter 1
Introduction to
Java Programming
Introduction
1.1 Basic Computing Concepts
Why Programming?
This chapter begins with a review of some basic terminology about com-
puters and computer programming. Many of these concepts will come up
in later chapters, so it will be useful to review them before we start delv-
ing into the details of how to program in Java.
Hardware and Software
The Digital Realm
The Process of Programming
Why Java?
The Java Programming
Environment
We will begin our exploration of Java by looking at simple programs that
produce output.This discussion will allow us to explore many elements
that are common to all Java programs, while working with programs that
are fairly simple in structure.
1.2 And Now—Java
String Literals (Strings)
System.out.println
Escape Sequences
print versus println
After we have reviewed the basic elements of Java programs, we will
explore the technique of procedural decomposition by learning how to
break up a Java program into several methods. Using this technique, we
can break up complex tasks into smaller subtasks that are easier to man-
age and we can avoid redundancy in our program solutions.
Identifiers and Keywords
A Complex Example:
DrawFigures1
Comments and Readability
1.3 Program Errors
Syntax Errors
Logic Errors (Bugs)
1.4 Procedural Decomposition
Static Methods
Flow of Control
Methods That Call Other
Methods
An Example Runtime Error
1.5 Case Study: DrawFigures
Structured Version
Final Version without
Redundancy
Analysis of Flow of Execution
1
 
Search WWH ::




Custom Search