public class TestArrayList {
public static void main(String[] args) {
List<String> list = new ArrayList<String>() ;
list.add(“AAA”);
list.add(“BBB”);
list.add(“CCC”);
System.out.println(Arrays.toString(listToArray(list)));
System.out.println();
list = arrayToList(listToArray(list)) ;
for(String l : list){
System.out.println(l);
}
}
public static String[] listToArray(List<String> list){
return (String[]) list.toArray(new String[list.size()]) ;
}
public static List<String> arrayToList(String[] array){
return Arrays.asList(array) ;
}
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/195258.html