答案是肯定的!
public class Demo01{
private Listlist = new ArrayList ();
public Liststore(E[] arr){
list = Arrays.asList(arr);
return list;
}
public static void main(String[] args) {
Demo01d = new Demo01<>();
String animals[] = {"Cat","Dog","Pig","Monkey"};
Listlist = d.store(animals);
for (String string : list) {
System.out.print(string + "\t");
}
}
}
可以,返回值必须限定是某一类型
可以!!返回值必须是你定义的类型包含的泛型也必须一样