今天写了一个返回泛型的方法:
public <T> T returnTypeList(String type){ T t=null; switch(type){ case "film": t=(T) film; break; case "audio": t=(T) audio; break; case "word": t=(T) word; break; case "img": t=(T) img; break; case "jar": t=(T) jar; break; case "excal": t=(T) excal; break; case "ppt": t=(T) ppt; break; case "pdf": t=(T) pdf; break; } return t; }
其中,jar和pdf是字符串,其他返回类型都是List