How do you test code that uses PECS principle?

In Java, the PECS principle stands for "Producer Extends, Consumer Super". It is used to determine when to use wildcards in generics. When you're working with a class or interface that produces values, you should use the `extends` wildcard. Conversely, when you are consuming values, you use the `super` wildcard. Testing code that adheres to the PECS principle is essential to ensure type safety and proper usage of generics.

Here’s a simple example illustrating the PECS principle:

numbers) { foreach ($numbers as $number) { echo $number . "\n"; } } } // Consumer - Using super class NumberConsumer { public function consumeNumbers(List super Integer> integers) { $integers[] = new Integer(10); $integers[] = new Integer(20); } } ?>

PECS Java Generics Wildcards Producer Extends Consumer Super Type Safety