SPUG: Unidentified Flying Objects

Adrian Hands AEH at akc.org
Tue Jan 10 11:21:08 PST 2006

> something is. But sometimes you don't yet in the course of executing a
> behavior it becomes obvious what it is.

so, you do a cast, but from Flyer to Plane (or Flyer to Bird), but not
Bird to Plane.

  Flyer ufo = new Bird();
  ( (Plane) ufo ).on_a_typical_day(); 
  // you'll get a ClassCastException at runtime.

When is it a good idea to change a bird into a plane?

More information about the spug-list mailing list