Values and Expressions
Variables and assignment
- Scope is a way of describing the part of a program in which a variable has a meaning.
- Java uses block scope
- Use the narrowest scope you can as it reduces the number of things you have to think about. (When you leave a scope it’s like crossing an item off your todo list.)
- Variables also have “extent” which is how long they exist in time. For intstance the parameters of a method are scoped to the body of the method (can only be referred to within the text of the method) and have exent of the duration of the method call—once the method returns the variables no longer exist. (Though when the method is called again, a new set of variables will come into existance and last for as long as that method call takes.)
- Local variables shadow member variables
- Local variables cannot shadow other local variables—it’s a compile error because it’s a somewhat common mistake. This is not true in, for instance, Javascript.
var
can save you a bunch of typing (both kinds)
Arrays
- Memory layout of 2D arrays.
- Ragged arrays
- Using 1D arrays for 2D data
Control constructs
- if
- for / while, enhanced for
- switch
- do/while
- break and continue
- labeled break and continue in loops
- labeled blocks and break
Methods
Writing classes
Built in classes
Inheritance
- Interfaces
- Abstract classes
OO design
- All the access modifiers
- OO design
Algorithms