Created
August 1, 2012 17:32
-
-
Save soc/3229086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package zoo; | |
class Animal {} | |
class Lion extends Animal {} | |
class Cage<T extends Animal> { | |
void add(T animal) { System.out.println("Adding animal..."); } | |
public static void main(String... args) { | |
Cage<? extends Animal> animals = null; | |
Cage<Lion> lions = null; | |
animals = lions; | |
animals.add(new Lion()); //ERROR | |
} | |
} | |
/* | |
The method add(capture#2-of ? extends Animal) in the type Cage is not applicable to for the arguments (Lion) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment