1.导入hutool的maven依赖
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>
2.直接复制代码运行
import cn.hutool.core.convert.Convert;
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String[] args) throws Exception {
List<Long> list = new ArrayList<>();
list.add(1L);
list.add(2L);
list.add(3L);
String[] strArray = Convert.toStrArray(list);
System.out.println(strArray);
//转换回去
List<Long> reverse = Convert.toList(Long.class, strArray);
System.out.println(reverse);
}
}