是否有一个实用方法,可以在1行完成这个?我在Collections
或List
中找不到它。
public List<String> stringToOneElementList(String s) {
List<String> list = new ArrayList<String>();
list.add(s);
return list;
}
我不想重新发明轮子,除非我打算把花哨的轮辋上。
嗯…类型可以是T
,而不是String
。但你懂的。(所有的空检查,安全检查…等)