public class CovariantArrayDemo {

    static class Animal {}
    static class Dog extends Animal {}
    static class Cat extends Animal {}

    public static void main(String[] args) {
        Animal[] animals = new Dog[10];       // Covariance, hmmm
        try {
            animals[0] = new Cat();
        } catch (ArrayStoreException e) {
            System.out.println("Runtime type checking!");
        }
    }
}

public class CovariantArrayDemo {

    public static void main(String[] args) {
        Animal[] animals = new Sheep[10];       // Covariance, sadly
        try {
            animals[0] = new Cow("Bessie");
        } catch (ArrayStoreException e) {
            System.out.println("Runtime type checking!");
        }
    }
}

Use existing classes for the covariance example
Use existing classes for the covariance example
