What is PECS (Producer Extends Consumer Super) in Java generics?
Hi everyone! I've been writing Java for a few months now, but I still get confused with wildcards in generics. I read about PECS, but in practice I still don't understand when to use `? extends T` and when to use `? super T`.
Here's a specific example that confuses me. I have a method that should copy elements from one list to another:
```java
public static void copy(List> src, List> dest) {
for (Object item : src) {
dest.add(item); // Compilation error!
}
}
```
The compiler complains about `dest.add(item)`. I understand that I need to use bounded wildcards, but I can't figure out which ones.
Let's say I have a class hierarchy: `Animal` → `Dog` → `Puppy`. I want to write a method that:
1. Reads objects from a list (e.g., a list of `Dog`)
2. Wr