Computer Science 225
Advanced Programming
Spring 2022, Siena College
Lecture 4: More Interfaces; Anonymous Classes
Date: Monday, February 7, 2022
Agenda
- Announcements
- Problem Set 1 and Lab 1: Java and Data Structures Refresher (in Canvas and GitHub)rading complete and video recaps of both are now available
- Lab 2: Java Interfaces (in Canvas and GitHub) due 24 hours before your next lab
- Problem Set 2 is now out, see links in Canvas
- you may work alone or with a partner and all groups must be
formed and all repositories must be created (even for those
working along) by Wednesday
- email me if looking for a group and I can match people up
- video intro in Canvas
- a quick memory diagram refresher from data structures
- due in a week
- Check in Canvas for Lab 3 to see if you're the document and
repository creator and do those if you are
- Java Interfaces
- creating interfaces
- anonymous classes
- casts and instanceof
- In-class exercises (5 assignment points), answer in a Google
document "LastNameInClass4" in your CSIS225 folder
- Write the Java statement that would implement sorting of our
array of Animal objects in the ZooArray example, this
time by number of legs from largest to smallest, using a
Comparator defined as an anonymous class passed directly as
a parameter to the Arrays.sort method.
- What changes would need to be made to the Dog class to
implement the Comparable interface, defining the ordering
based on a new int-valued field age?
Terminology
- instanceof operator
- cast
- anonymous class
Examples