java中集合框架的需求是什么? [英] What is the need of collection framework in java?

查看:257
本文介绍了java中集合框架的需求是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java中对Collection框架的需求是什么,因为所有数据操作(排序/添加/删除)都可以使用Arrays,而且数组适合于内存消耗,并且与Collections相比性能也更好。

What is the need of Collection framework in Java since all the data operations(sorting/adding/deleting) are possible with Arrays and moreover array is suitable for memory consumption and performance is also better compared with Collections.

有人能指出一个实时数据导向的例子,它显示了这些实现的两个(数组/集合)的差异。

Can anyone point me a real time data oriented example which shows the difference in both(array/Collections) of these implementations.

推荐答案


  • 数组不可调整大小。

  • Java Collections Framework提供了许多不同的有用数据类型,例如作为链接列表(允许在恒定时间内任意位置插入),可调整大小的数组列表(如 Vector 但更酷),红黑树,基于哈希的映射(如 Hashtable 但更酷)。

  • Java Collections Framework提供抽象,因此您可以将列表称为 List ,是否由数组列表或链表支持;并且您可以将地图/字典称为地图,无论是由红黑树还是哈希表支持。

    • Arrays are not resizable.
    • Java Collections Framework provides lots of different useful data types, such as linked lists (allows insertion anywhere in constant time), resizeable array lists (like Vector but cooler), red-black trees, hash-based maps (like Hashtable but cooler).
    • Java Collections Framework provides abstractions, so you can refer to a list as a List, whether backed by an array list or a linked list; and you can refer to a map/dictionary as a Map, whether backed by a red-black tree or a hashtable.
    • 换句话说,Java Collections Framework允许您使用正确的数据结构,因为一个大小并不适合所有。

      In other words, Java Collections Framework allows you to use the right data structure, because one size does not fit all.

      这篇关于java中集合框架的需求是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆