字符串转list 实现List集合中数据逆序排列实现List集合中数据逆序排列

阅读 52

2022-06-20

字符串转list   

/**
* 字符串转list
*/
public static List<String> strSplitToList(String str, String regex) {
List<String> list = new ArrayList<>();
if (str != null) {
if (str.contains(regex)) {
Collections.addAll(list, str.split(regex));
} else {
list.add(str);
}
}
return list;
}

实现List集合中数据逆序排列

Collections.reverse(list);     实现list集合逆序排列



精彩评论(0)

0 0 举报