int array[]=new int[list.size()];是这个意思么

解决方案 »

  1.   

    java 中的"所有"数组全部是动态数组
      

  2.   

    如果[java 中的"所有"数组全部是动态数组]那麼,下面就是正確的了?
    String[] name;
    name[0]="test0";
    name[1]="test0";
    name[2]="test0";
    name[3]="test0";
     ..  ..=" .. ";
     ..  ..=" .. ";
     ..  ..=" .. ";
    很多!
      

  3.   

    用ArreyList, 通过add方法添加ArrayList()constructs an empty array list.ArrayList(int initialCapacity)constructs an empty array list with the specified capacity.Parameters:
     initialCapacity
     the initial storage capacity of the array list
     
    boolean add(Object obj)appends an element at the end of the array list. Always returns true.Parameters: 
     obj
     the element to be added
     
    int size()returns the number of elements currently stored in the array list. (This is different from, and, of course, never larger than, the array list's capacity.)void ensureCapacity(int capacity)ensures that the array list has the capacity to store the given number of elements without relocating its internal storage array.Parameters: 
     capacity
     the desired storage capacity
     
    void trimToSize()reduces the storage capacity of the array list to its current size.
      

  4.   

    在new 一个数组之前可以知道其长度的,可用 Object[] = new Object[length];
    无法知道长度的,或者长度在增长时,该数组必须参与运算的,可用ArrayList,Vector等
      

  5.   

    to 楼主:我所说的动态数组是指
    int i = 10;
    int[] array = new int[i];
    静态数组是指
    int array[10];至于你说的那种情况, 效果上可以通过 ArrayList 实现
    但是实际上 ArrayList 也是通过数组实现的, 只不过把数组包装了一下String[] name;
    name[0]="test0";
    name[1]="test0";
    name[2]="test0";
    name[3]="test0";
     ..  ..=" .. ";
     ..  ..=" .. ";
     ..  ..=" .. ";
    很多!你所想像的这个"动态"数组这个世界上是不存在的
    如果存在那他的名字就不叫"数组"了推荐你学习一下内存分配的相关知识
    http://blog.csdn.net/hustli/category/12737.aspx