list对象转数组
代码语言:javascript复制package com.example.core.mydemo.json5;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* list对象转数组
*/
public class ArrayTest {
public static void main(String[] args) {
List<String> timesNoList = new ArrayList<>();
timesNoList.add("AAA");
timesNoList.add("BBB");
timesNoList.add("CCC");
if(CollectionUtils.isNotEmpty(timesNoList)) {
String[] str = timesNoList.stream().toArray(String[] :: new);
for (int i = 0; i < str.length; i ) {
System.out.println("array = " str[i]);
}
}else{
System.out.println("bbb");
}
}
}