list对象转数组
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"); } } }
标签:String,对象,list,timesNoList,add,str,数组,import From: https://www.cnblogs.com/oktokeep/p/17841110.html