Download Covariant.java source file
/** Demo of covariant return types.
*
* @author Wayne Pollock, Tampa Florida USA
*/
class Covariant implements Cloneable
{
public Covariant clone() throws CloneNotSupportedException
{
return (Covariant) super.clone();
}
public static void main ( String [] args )
throws CloneNotSupportedException
{
Covariant c1 = new Covariant();
Covariant c2 = c1.clone(); // No cast needed!
}
}