Variable Types
  1. Primitives: int, double, boolean ("clock" analogy for overrunning bounds of int)

  2. Wrapper classes: Integer, Double, Boolean
    Example: Integer myInteger = new Integer( 10 );
    Example: Double myDouble = new Double( 3.14 );
    Example: Boolean myBoolean = new Boolean( true );

  3. Java Constants (new for 2010 and 2011)
    Integer.MAX_VALUE
    Integer.MIN_VALUE
    This will help with the reading of exam questions that presently contain comments such as < some integer value > and will reiterate that there are maximum and minimum values for integers.

  4. Static variables (aka "class variables") (new for 2010 and 2011)
    Static final variables will continue to be a part of the Course Description.

  5. Strings
    Example: String myName = new String( "Mud" );
    Example: String myName = "Mud";

    String Pooling Problem
    String s1 = "Harry Potter"; //case 1
    String s2 = "Harry Potter"; //case 2

    In case 1, literal s1 is created newly and kept in the pool. But in case 2, literal s2 refer the s1, it will not create new one instead.

    if(s1 == s2)
       System.out.println("equal"); //Prints equal.

    String n1 = new String("Harry Potter");
    String n2 = new String("Harry Potter");
    if(n1 == n2)
       System.out.println("equal"); //No output.

    Moral of the story: Always use "new" when creating Strings!

  6. 1D and 2D Arrays (2D arrays new for 2010 and 2011)
    Example: int[] myArray = new int[10]; // 1D array of primitives
    Example: int[][] myArray = new int[10][10]; // 2D array of primitives
    Example: String[] myArray = new String[10]; // 1D array of Objects
    Example: String[][] myArray = new String[10][10]; // 2D array of Objects
    Example: List[][] myArray = new List[10][10]; // 2D array of objects that implement List interface

    Projects: "Memory!", "Battleship"

  7. ArrayList
    Exampe: List< Integer > someArrayList = new ArrayList< Integer >();
    (note: List reference to an ArrayList...new in 2010)

  1. Mathematical
    1. +, -, *, /, %
    2. ++, --
    3. +=, -=
    4. + (String concatenation)
  2. Relational
    1. ==, !=, < , <=, >, >=
  3. Logical
    1. &&, ||
    2. !

Iteration

  1. for loop
    for( int index = 0; index < someArrayList.size(); index++ )
       {
       }

    for( int index = 0; index < someArray.length; index++ )
       {
       }

  2. for each loop ( aka enhanced for )
    Usually not good for processing loops since there is no index counter to use; e.g. someArrayList.remove(ctr)

    for( Car c : garageOfCars )
       {
       System.out.println( c.getName() );
       }

  3. while loop
    while( ctr < 100 )
       {
       ctr++;
       }

  4. The classic "for loop removal" problem
    When removing adjacent elements in an ArrayList, an element may be missed if loop counter is not adjusted.

    Possible solutions:
    (a) decrement counter, OR
    (b) use "while" instead of "if" within the body loop (elegant solution)

Decision-Making

  1. if statement
  2. if else statement
  3. switch statement (not tested)

Comparing Primitives and Objects

  1. Use == to compare primitives
  2. Use .equals() OR compareTo( Object o ) to compare objects
  3. Using "==" with objects only check to see if to references point to the same object! Only use if you want this!

Classes

  1. Instance variables
  2. Methods: getters and setters (or accessors and mutators)
  3. Constructors
  4. Uses of "this" ( this.yourValue and this() )
  5. toString() method
  6. Visibility: "private" and "public" (no "protected")
  7. Class Design - Projects where students are required to design their own classes

Inheritance

  1. Abstract classes
  2. Interfaces (100% abstract class!)
  3. Polymorphism (Using superclass references for subclass objects)
  4. Reference types: concrete classes, abstract claseses, interfaces
  5. Uses for super ( super.yourMethod and super() in constructors)

1. Searching and Sorting
Google "searching and sorting simulations" for great graphical simulations of all types of sorts.
MathSite Searching/Sorting Simulations
Big-O Tutorial
  1. Sequential search
  2. Binary search
  3. Selection sort
  4. Insertion sort
  5. Mergesort (use students on stairs to show levels of recursion)

Here is the mini-project description for the Sorting/Searching Project
Sorting and Searching Mini-Project
Sorting and Searching Mini-Project Rubric (.pdf)
Sorting and Searching Mini-Project Rubric (.xls)
Timer/Stopwater Test Bench (.html)

Some Search/Sorting Role Play Picutures
Sort 1  Sort 2  Sort 3
Sort 4  Sort 5  Sort 6
Sort 7  Sort 8  Sort 9
Sort 10  Sort 11  Sort 12


2. Recursion (introduce with Mergesort algorithm, fractals, Fibbonacci sequences)

3. Number System Conversion (dec, bin, hex, oct)
Teaching the binary number system
Counting Octopus on YouTube

Q: Why do computer scientists confuse Halloween and Christmas?
A: Because they can't tell the difference between 31Oct and 25Dec.

faqs   pedagogy   content   eThreads
daily schedule

*AP is a registered trademark of the College Board
© 2008-2012 Michael Lew