Monday, June 26, 2006
Update - generics puzzles
After my post yesterday, Tristan Allwood and Nick Cameron both wrote to offer some help. When you want a list of things that implement both interface A and interface B, the syntax that you need is:
List<T extends A & B>
. Yes, that's an ampersand. Ugly isn't it. To make matters worse, this syntax doesn't mix well with wildcards, so you can't write List<? extends A & B>
. Instead you have to write <T extends A & B> void m(List<? extends T>) { ... }
.