This is a first course in Computer
Science using the programming language Java. It covers the fundamentals of
programming and of computer science.
For maximum benefit, study
these notes interactively, thinking about and answering the question at the
bottom of each page. There are about 20 pages per chapter. If you spend about 3
minutes per page each chapter will take about 60 minutes,
or longer if you copy and run some of the programs. If you are a beginning
programmer, plan on spending more than a month with this.
These notes assume that you
have the Java version 5.0 or later from Sun Microsystems, Inc. at java.sun.com and a text editor such as Notepad.
They may be used with more sophisticated environments, as well. For more about
these notes check the frequently asked questions.
Best viewed at
800 x 600 or higher
This downloaded zip-file
version of the notes does not contain the audio portion.
Part 1: Hardware and Software
|
||||
|
|
Computer Systems |
|||
|
|
Analog and Binary Signals |
|||
|
|
Computer Memory |
|||
|
|
The Processor |
|||
Part 2: Running Java Programs
|
||||
|
|
Introduction to Java |
|
||
|
|
Small Java Programs |
|
||
|
|
How to Run the Example Programs |
|
||
Part 3: Data
|
||||
|
|
Primitive Data |
Exercises
and Flash Cards |
||
|
|
Variables and the Assignment Statement |
|||
|
|
Expressions and Arithmetic Operators |
|||
|
|
Object Data |
|||
|
|
Input and Output |
|||
|
|
Floating Point |
|||
Part 4: Branches and Loops
|
||||
|
|
The |
|||
|
|
The Single
Branch |
|||
|
|
Boolean
Expressions |
|||
|
|
Loops and the
|
|||
|
|
Counting
Loops |
|||
|
|
Nesting Loops
and Ifs |
|||
|
|
Sentinel-controlled
Loops |
|||
|
|
Result-controlled
Loops |
|||
|
|
Random
Numbers |
|||
Part 5: File Input and Output
|
||||
|
|
Files and
File Redirection |
|||
|
|
Reading Data
with File Redirection |
|||
|
|
I/O using
Scanner and PrintStream |
|||
|
|
File Input
Techniques |
|||
|
|
Formatted
Output |
|||
Part 6: Object Oriented Programming
|
||||
|
|
Objects |
|
||
|
|
Object References |
|
||
|
|
More about Objects and Classes |
|
||
|
|
Method Parameters |
|
||
|
|
Strings and Object References |
|||
|
|
More about Strings |
|||
|
|
Defining your own Classes |
|||
|
|
Class Design Example (miles per gallon) |
|||
|
|
Class Design Example (checking account) |
|||
|
|
Encapsulation and Visibility Modifiers |
|||
|
|
Parameters, Overloading, Local Variables |
|
||
|
|
Object Parameters |
|
||
|
|
Objects that Contain Objects |
|||
Part 7: Applets and Graphics
|
||||
|
|
Applets |
|||
|
|
Applet Examples |
|||
|
|
More Applet Examples |
|||
Part 8: More Java Features
|
||||
|
|
Increment, Decrement, and Assignment Operators |
|
||
|
|
Boolean Expressions and Short-circuit Operators |
|
||
|
|
Truth Tables and De Morgan's Laws |
|
||
|
|
The |
|||
|
|
More about the |
|||
|
|
The Conditional Operator and the |
|||
|
|
The |
|||
|
|
||||
Part 9: Arrays
|
||||
|
|
Arrays |
|||
|
|
Common Array Algorithms |
|||
|
|
Arrays as Parameters |
|||
|
|
Methods that Change Arrays |
|
||
|
|
Arrays of Objects and Linear Search |
|||
|
|
Two-dimensional Arrays |
|||
|
|
StringBuffers |
|||
Part 10: Advanced Object Oriented Programming
|
||||
|
|
Inheritance |
|
||
|
|
Abstract Classes and Polymorphism |
|
||
|
|
More about Polymorphism |
|
||
|
|
Interfaces |
|
||
|
|
The Comparable Interface |
|||
|
|
ArrayLists
and Iterators |
|
||
Part 11: Graphical User Interface Programming
|
||||
|
|
GUI Programming |
|
||
|
|
JFrames |
|
||
|
|
Adding Buttons to a JFrame |
|||
|
|
Buttons and Action Events |
|||
|
|
JTextFields
and JLabels |
|||
|
|
GUI Applications |
|||
|
|
JPanel
and BoxLayout |
|
||
|
|
Radio Buttons and BorderLayout |
|
||
|
|
JSliders
and Change Events |
|
||
Part 12: Recursion
|
||||
|
|
Recursion |
|||
|
|
Recursion in Java |
|||
|
|
Examples of Recursion |
|||
|
|
More Recursion |
|||
|
|
Recursion with Graphics |
|
||
Part 13: Exceptions and IO Streams
|
||||
|
|
Exceptions and Errors |
|||
|
|
More about Exceptions |
|||
|
|
Input and Output Streams |
|
||
|
|
Writing Text Files |
|||
|
|
Reading Text Files |
|||
|
|
Writing Binary Files |
|||
|
|
Reading Binary Files |
|||
|
|
The File Class |
|||