Incremental Java
Introduction
Teaching Programming
What is Programming?
Behind the Curtain: A Peek at a Java Class
Boxes and Values
Multiple Boxes
Boxes Have Types
Primitive Types
Introduction
Int
Double
Char
Boolean
Variable Names
Identifiers: Giving Names to Boxes
Java Style Variable Names
Descriptive Variable Names
Whitespace
Declaring Primitive Variables
Initializing Primitive Variables
Declaring Variables in a Java Program
Expressions and Evaluations
Expressions
Evaluating Expressions
Side Effects
Associativity
Precedence
Logical Operators
Equality Operators
Relational Operators
Integer Division
Modulus Operator
Mixed Type Expressions
Initialization, Again
Side Effecting Expressions: Increment/Decrement
Introduction to Objects using Strings
Math Strings
Objects and Strings
Declaring Object Variables
Strings are Immutable
Assignment Statements
Assignment Statements
Compound Assignment Statements
Printing to Screen
A Simple Class
A Simple Class
A Java File
Exercises
Associativity and Precedence
Guess what's printed?
Design, Edit, Compile, Run, Debug
Overview
Edit
Compile
Run
Debug
Integrated Development Environment
Summary
Objects
Review of Objects
Abstraction
Object Users and Class Designers
Classes and Objects
Objects Respond to Commands (i.e., Methods)
Method Signatures
Objects are Containers for Instance Variables
Constructors, Part 1
Arguments and Method Calls
Testing a Class
Parameters and Method Definitions
Local Variables, Scope, and Lifetime
Constructors, Part 2
Writing a Class Definition
Testing a Class, Part 2
Private Methods
Overloading Methods
Interfaces
Inheritance
Basic Inheritance
Can Only Extend One Class
Overriding Methods
Dynamic Dispatch
Constructors and Inheritance
Abstract Classes
Object: The Mother of All Classes
Accessing Instance Variables from Parameters
Static Methods
Control Flow
What is Control Flow?
Conditions
DeMorgan's Theorem and Negating Conditions
Blocks
Conditional Statements
if
if-else
Style: Indenting if, if-else, and method bodies
Nested if
Dangling Else
Prioritized if
switch
Conditional Expressions (Question Mark, Colon)
Adding Conditional Statements to a Class
Implementing
equals()
using
instanceof
Loops
Introduction to loops
while loops
while
: Syntax and Semantics
Example: Printing 1 to
num
Example: Printing 0 to
num - 1
Example: Sum 1 to
num
Definite and Indefinite Loops
Counting Iterations
Looping Variables
No Iterations
do-while
for
Comma Operator
Loop postconditions
Example: print
num
stars
Nested loops
Infinite loops
break
and
continue
Equivalence of loops
Style: Indenting loops
Adding Loops to a Class
Container Classes
What is a container?
API
ArrayLists
Introduction to ArrayLists
ArrayList API
Learning about ArrayList with a test class
Test Class with ArrayList
Printing a List Backwards
Swapping Two Elements in an ArrayList
The Problem With Swapping Ints
Reversing an ArrayList
Example: Dean's List
Arrays
Why Arrays? An Introduction to Arrays
Arrays: Length vs. Index
Array Idioms
What's an Idiom?
Copying Arrays
Better Way to Copy Arrays
Remove and Shift
Insert and Shift
Implementing a Simple ArrayList