Topic: 关于集合

  Print this page

1.关于集合 Copy to clipboard
Posted by: ice0819
Posted on: 2008-11-01 20:15

List<T> list=new ArrayList<T>;与ArrayList<T> list=new ArrayList<T>;有什么区别呀?前者有点在哪?

2.Re:关于集合 [Re: ice0819] Copy to clipboard
Posted by: andy_wang_5
Posted on: 2008-11-03 09:02

前者使用了upcase(上塑类型转化)

3.Re:关于集合 [Re: andy_wang_5] Copy to clipboard
Posted by: ditty
Posted on: 2008-11-03 10:41

前者通用性好些。

4.Re:关于集合 [Re: ice0819] Copy to clipboard
Posted by: junz04
Posted on: 2008-11-04 22:07

这样做具有很好的灵活性,如果将来程序需要重构的话,比如说需要使用LinkedList而不是ArrayList的话,只需改成List<T> list=new LinkedList<T>;就可以实现了,其他代码都不用更改。

5.Re:关于集合 [Re: ice0819] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-11-10 17:57

Under almost all circumstances, we should use the former one, i.e. List<T> list=new ArrayList<T>; instead of ArrayList<T> list=new ArrayList<T>;

This is the underpinning idea of OO polymorphism.

My one cent.
Jiafan


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923