CS 245 Lecture 12 – Generic Sorted List
Agenda
- what ?s
- what does this do?
- polymorphism: inheritance and parametric
- program this
What Does This Do?
What happens when someone calls Main.print?
class Foo {
public String toString() {
return "yargles";
}
}
class Main {
...
public void print(Foo f) {
System.out.println(f.toString());
}
}
Program This
You have a sorted array of ints, but it’s not filled to capacity. Someone hands you another int. How can you insert it and keep the list sorted? Write something down.
Code
…
Haiku
generic love
Don’t lower standards
Wait for her to define them
Love T, for some T
Don’t lower standards
Wait for her to define them
Love T, for some T