Why is it not possible use primitive types with polymorphic return types?
问题 Consider the following two classes: public interface Foo<T> { public T moo(); } public class IntFoo implements Foo<Integer> { public int moo() { return 0; } } This code will produce an error at public int moo , saying that int is incompatible with the overridden method's return type Integer . Strictly speaking, this is true, since int does not directly equal Integer . However, we all know that they can be implicitly converted to each other using auto(un)boxing. What is less know is the fact