返回不同的POJO我想返回一个不同类型的列表如何使用Java泛型
的方法,我试图像下面,但不知道这种做法是否正确。有人可以帮助我如何做到这一点?
public <T> List<T> getPageDetails(Long adId,String source);
并根据source
我会在实现方法返回不同的List of objects
。
like in implementation if the source is 1, then will have to return List of objects type1 if the source is 2 then list of objects type2 etc
plaese阐述更多。 –
你不想要返回一个列表吗?所以肯定'公众列表 getPageDetails(长adId,字符串源);'会更有意义? –