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) ;
}
}
转载于:https://blog.51cto.com/11130069/1981953