泛型与方法重载
我有3种方法:
//1 -- check one item
public static <T> void containsAtLeast(String message,
T expectedItem,
Collection<? extends T> found) {
if (!found.contains(expectedItem))
Assert.fail("...");
}
//2 -- check several items
public static <T> void containsAtLeast(String message,
Collection<? extends T> expectedItems,
Collection<T> found) {
for (T exptetedItem : expectedItems)
containsAtLeast(message, exptetedItem, found);
}
//3 -- check several items, without message parameter
public static <T> void containsAtLeast(Collection<? extends T> expectedItems,
Collection<? extends T> found) {
containsAtLeast(null, expectedItems, found);
}
我希望该方法调用,但它没有,它调用方法。我的期望是否有错误?//3
//2
//1
*我使用 sdk 1.7.0_25 和 Eclipse 4.3*