MCS-287 Notes for 2006-02-20

First, we will finish off our variant TokenStream programs from last time. (The link leads to the version we ended with.) Specifically, we still need to write a program that prints out each distinct token together with a count of how many times it appears in the input. This will give us an opportunity to use the Map interface and HashMap class, as well as to see how the Integer wrapper class can be used with autoboxing and autounboxing. Added after class: here is the version we ended up with.

Next, we can take a look at nested use of generic classes, for example a Stack of Sets of Strings.

Our third topic will be a look at the subtyping relationship with generic classes. An Integer is a kind of Number. Does that mean that a Set of Integers is a Set of Numbers? It sounds logical, but we need to be careful, among other reasons because the Java notion of a Set is different from how we use that same word in mathematics. To see whether the proposed subtyping makes sense, we'll have to think about what our expectations are for a Set of Numbers and see whether a Set of Integers can meet all those expectations. On the other hand, a Set of Integers definitely is a Collection of Integers, from the fact that Set is a subtype of Collection.

Finally, if time permits, we will consider the most basic use of wildcards, where the wildcard is not bounded. (Time didn't permit.)

Course web site:
Instructor: Max Hailperin <>