就是把一个List转化为数组
反之

解决方案 »

  1.   

    List的toArray方法,得到一个数组.
      

  2.   

    Arrays.asList()可以把从一个数组得到一个List
      

  3.   

    import java.util.Arrays;
    import java.util.List;
    public class Main {    public static void main(String[] args) {
            String[] array = {"Hello","world","!"};
            for(String str:array){
                System.out.print(str+" ");
            }
            System.out.println();
            List<String> list = Arrays.asList(array);
            System.out.println(list);
            String[] array2=(String[])list.toArray();
            for(String str :array2){
                System.out.print(str+" ");
            }
            System.out.println();
        }
    }
      

  4.   

    List类中:提供两个方法:toArray
    Object[] toArray()返回以正确顺序包含列表中的所有元素的数组。遵守 Collection.toArray 方法的常规协定。 指定者:
    接口 Collection<E> 中的 toArray
    返回:
    以正确顺序包含该列表中所有元素的数组。
    另请参见:
    Arrays.asList(Object[])--------------------------------------------------------------------------------toArray
    <T> T[] toArray(T[] a)返回以正确顺序包含列表中所有元素的数组;返回数组的运行时类型是指定数组的运行时类型。遵守 Collection.toArray(Object[]) 方法的常规协定。 指定者:
    接口 Collection<E> 中的 toArray
    参数:
    a - 要存储列表中元素的数组,如果它足够大的话;否则为此目的分配一个运行时类型相同的新数组。 
    返回:
    包含列表中元素的数组。 
    抛出: 
    ArrayStoreException - 如果指定数组的运行时类型不是此列表中每个元素的运行时类型的超类型。 
    NullPointerException - 如果指定数组为 null。
      

  5.   

    Arrays类中提供了数组转换为List类的方法:asList
    public static <T> List<T> asList(T... a)返回一个受指定数组支持的固定大小的列表。(对返回列表的更改会“直写”到数组。)此方法同 Collection.toArray 一起,充当了基于数组的 API 与基于 collection 的 API 之间的桥梁。返回的列表是可序列化的,并且实现了 RandomAccess。 
    此方法还提供了一个创建固定长度的列表的便捷方法,该列表被初始化为包含多个元素:      List stooges = Arrays.asList("Larry", "Moe", "Curly");
     
    参数:
    a - 支持列表的数组。 
    返回:
    指定数组的列表视图。
    另请参见:
    Collection.toArray()
    以上是JavaAPI中的内容,
    举例子,上面企鹅兄已经写出来了,
    我来晚了!