Dec 4, 2012

Java Generics and PECS Rule

Java Generics and PECS Rule
The fad behind the Arrays and the generic Collections is defined by this two important scenarios: Arrays are covariant(Widening their reference) while Collections are invariants(Narrowing their reference). When it comes to input parameters it becomes clear that these two containers differ largely and requires extra careful approach. for instance if a class of Foo is a subtype of another class Foobar then the array of type Foo[] is a subtype of Foobar[].