List是一个抽象类,因此你如果使用ArrayList的时候,一般的都会写成: ArrayList al = new ArrayList(); 但是这种写法不好,在《java 与 模式》中提倡List al = new ArrayList(); hehe
public interface List extends Collection ---------------------- 说List是类的那位,和楼上那位说List是一个抽象类。 那位说是类的还号称看了帮助文档。你们是怎么学习的?
在《java 与 模式》中提倡List al = new ArrayList(); ------------------------- 这样是叫 “对接口编程而不对具体实现编程”。
提倡List al = new ArrayList();
List al = new ArrayList(); 是啊我的部长就是这么告诉我的
java.awt Class List java.lang.Object java.awt.Component java.awt.ListAll Implemented Interfaces: Accessible, ImageObserver, ItemSelectable, MenuContainer, Serializable public class List extends Component implements ItemSelectable, Accessible The List component presents the user with a scrolling list of text items. The list can be set up so that the user can choose either one item or multiple items. 我看文档上是这样写的啊,是类吧! zhouyunlong(天王斩鬼刀) 你的那个interface在哪里看的????
The List component presents the user with a scrolling list of text items. The list can be set up so that the user can choose either one item or multiple items.
List al = new ArrayList()
Voctor与List关键不同在于Vector中的方法是同步的而List却不是 不过调用Collection.synchronizedList()可将任一对象转换成“同步List”因而所有的方法都变得同步。 from 《JAVA2 类库》 SUN公司核心技术丛书 不过老了点
vector同步
api 上说的
一般用在线程上,其他情况下二者差不多一样
Vector和ArrayList是实现List接口的类。
Vector是线程安全的,ArrayList是线程不安全的。
线程安全的类在不使用多线程的环境下是没有意义,而且速度要慢一点。
ArrayList al = new ArrayList();
但是这种写法不好,在《java 与 模式》中提倡List al = new ArrayList();
hehe
extends Collection
----------------------
说List是类的那位,和楼上那位说List是一个抽象类。
那位说是类的还号称看了帮助文档。你们是怎么学习的?
-------------------------
这样是叫 “对接口编程而不对具体实现编程”。
是啊我的部长就是这么告诉我的
Class List
java.lang.Object
java.awt.Component
java.awt.ListAll Implemented Interfaces:
Accessible, ImageObserver, ItemSelectable, MenuContainer, Serializable public class List
extends Component
implements ItemSelectable, Accessible
The List component presents the user with a scrolling list of text items. The list can be set up so that the user can choose either one item or multiple items.
我看文档上是这样写的啊,是类吧! zhouyunlong(天王斩鬼刀) 你的那个interface在哪里看的????
如果你用过一段时间的话,那么我认为你学习有问题了。
你居然拿把util包里的List混到awt包里的List.
你让我怎么说你好呢?
from 《JAVA2 类库》 SUN公司核心技术丛书
不过老了点