本帖最后由 jpg1023_2009 于 2009-12-16 15:48:35 编辑

解决方案 »

  1.   

    arrayList适合排序
    linkedlist适合插入
      

  2.   

    Each ArrayList instance has a capacity. The capacity is the size of the array used to store the elements in the list. It is always at least as large as the list size. As elements are added an ArrayList, its capacity grows automatically. The details of the growth policy are not specified beyond the fact that adding an element has constant amortized time cost.An application can increase the capacity of an ArrayList instance before adding a large number of elements using the ensureCapacity operation. This may reduce the amount of incremental reallocation.
      

  3.   

    arrayList 适合查询
    linkedlist适合插入换成LinkedList 再试试。
      

  4.   

    因为在数量不断增加的同时,进行了多次数组拷贝,可以看一下ArrayList的add方法
      

  5.   

    能做的也就是用ArrayList(int capacity)构造,容量给大点,减少arraylist扩充次数。
    具体可以看add方法的实现,arraylist每次add前会检查容量,不够的时候要扩充。每次扩充就是建个新的数组,copy数据。
      

  6.   

    全部放内存中,不知道你内存有多大哦!!!关于这些集合的比较,可以google下,很详细滴
      

  7.   


    只是add对象,ArrayList效率要高一些。
      

  8.   

    楼上的错了,当add对象到达一定的量,大于当前的arrayList容量时,arrayList会增加当前的容量,重新在内存中分配空间,容量是当前容量的两倍,并把以前arrayList中的元素拷贝到新的arrayList中,效率随着元素的大量增加,重复大批量的元素拷贝而降低。
      

  9.   


    arraylist我还是知道的,可以看我在10楼的回复。
    至于效率,等我写段代码你去运行看看。
      

  10.   

    for循环LinkedList效率极低,最好减少循环次数再使用。public class A {
        public static void main(String[] args) {
            B b = new B(10000 * 100);
            System.out.println(b.fillAL());
            System.out.println(b.fillLL());
    //        System.out.println(b.forAL());
    //        System.out.println(b.forLL());
            System.out.println(b.iteAL());
            System.out.println(b.iteLL());
        }}class B {
        ArrayList al = new ArrayList();    LinkedList ll = new LinkedList();    int n;    B(int n) {
            this.n = n;
        }    long fillAL() {
            long s = System.currentTimeMillis();
            for (int i = 0; i < n; i++) {
                al.add(new Integer(i));
            }
            long e = System.currentTimeMillis();
            return e - s;
        }    long fillLL() {
            long s = System.currentTimeMillis();
            for (int i = 0; i < n; i++) {
                ll.add(new Integer(i));
            }
            long e = System.currentTimeMillis();
            return e - s;
        }    long forAL() {
            long s = System.currentTimeMillis();
            for (int i = 0; i < n; i++) {
                al.get(i);
            }
            long e = System.currentTimeMillis();
            return e - s;
        }    long forLL() {
            long s = System.currentTimeMillis();
            for (int i = 0; i < n; i++) {
                ll.get(i);
            }
            long e = System.currentTimeMillis();
            return e - s;
        }    long iteAL() {
            long s = System.currentTimeMillis();
            Iterator i = al.iterator();
            while (i.hasNext()) {
                i.next();
            }
            long e = System.currentTimeMillis();
            return e - s;
        }    long iteLL() {
            long s = System.currentTimeMillis();
            Iterator i = ll.iterator();
            while (i.hasNext()) {
                i.next();
            }
            long e = System.currentTimeMillis();
            return e - s;
        }
    }
      

  11.   

    我目前初始化是 new arraylist(5000). 用linklist的话要注意些什么呢。
      

  12.   


    能具体说说具体要那么多的数据做什么用么?性能基本上不会发生在 List 的身上,而是很可能发生在大量的结果集上。
      

  13.   


    LinkedList 使用 iterator 进行 for 循环时效率比 ArrayList 高很多,当然了,如果是使用下标随机访问的话效率远远没有 ArrayList 快,因为 ArrayList 使用数组实现的,随机访问速度非常快。for(Iterator<String> i = list.iterator(); i.hasNext(); )
      

  14.   

    一年的数据查询出来,然后前台分组织,分人员去抽取。 这样flex前台的速度就非常快。
    把取数放在后台。
      

  15.   

    首先,初始化的时候,可以初始化大些
    如果做统计,能用SQL语句直接进行分组等进行统计,为什么不用呢
    还是查询数据,没有用的,可以不查询出来,只查询需要的
    如果字段少,可以不用对象
      

  16.   

    呵,LZ的代码怎么这么像Kingdee的代码啊?
    是二次开发,还是在Kingdee做事呢?
      

  17.   


    运行上面那段代码就可以知道,add方法比ArrayList稍差一点,但影响不大;get方法效率极低,所以不要使用随机访问;用Iterator遍历效率比ArrayList高;如果在JSP中遍历,可以放心使用JSTL或者Struts标签循环,因为都是用Iterator遍历的。
      

  18.   

    我们是用flex 做前台。后天取数返回list
     as3会支持将list-->arraycollection 然后flex中的datagrid绑定这个arraycollection.
    所以前台报表展示的时候是不允许分页的。 要全盘展示。可搞不明白arraylist中塞入不到10000个对象。性能就差不行了。唉。
      

  19.   

    //以下的while循环语句耗费很多时间。当rs结果集仅仅到4000多的时候。
    while(rs.next()){
    bal = new AccountBal();
    bal.orgId= rs.getString("orgId");
    bal.budgetItem=(rs.getString("fbudgetitem"));
    bal.accountCode=(rs.getString("acctCode"));
    bal.newacctCode=(rs.getString("fnewaccountcode"));
    bal.newacctName=(rs.getString("fnewaccountname"));
    bal.period=(rs.getInt("fperiodnumber"));
    bal.pyear=(rs.getInt("fperiodyear"));
    bal.bal=(rs.getDouble("realValue"));
    bal.dbal=(rs.getDouble("otherValue"));
    bal.istotal=(rs.getBoolean("fistotal"));
    bal.isminus=(rs.getBoolean("fisminus"));
    bals.add(bal);