当我需要一串字符串,这俩种方法哪一种泛用性更高?
1:调用静态变量
public static final List<String> temp = new ArrayList<>();
static{
temp.add("test1");
temp.add("test2");
temp.add("test3");
}
2:调用方法
public static List<String> getTemp(){
List<String> temp = new ArrayList<>();
temp.add("test1");
temp.add("test2");
temp.add("test3");
return temp;
};