July 2002

Covariant Specialization Example

Here a small Java program that shows Java's static covariant method specialization. The program also demonstrates how dynamic dispatch would differ. You can download the source file here, but I imagine this page is good enough.

The most important thing to notice is that variable tempZ has the static type X, but the dynamic type Y.

Program Code

Program Output


July 16 2002, first writing