首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

java中ArrayList有什么用,举例说明?

马克-to-win:ArrayList是List接口的众多实现类其中的一个: 可以使我们快速访问元素,马克-to-win:为什么?因为它的内部组成结构就像Array一样,而且提供了可以直接访问第几个元素的方法比如下面例子中的get(index),但往其中插入和删除元素时,速度却稍慢。与LinkedList相比,它的效率要低许多。(因为LinkedList的内部像个Link, 参考数据结构)ArrayList遍历时要用到Iterator(见下)。(新手可忽略)和vector相比: (from java documentation: ArrayList is roughly equivalent to Vector, except that it is unsynchronized.()there is no synchronized keyword in the ArrayList source code.if multithread access ArrayList, you need to use synchroized keyword in your code yourself.).Vector是线程安全的,但多数情况下不使用Vector,因为线程安全需要更多的系统开销。

02
领券