关于Collection和Map的笔记

Java95

这两个在日常节目中使用得太频繁了,所以或多或少有必要把它们录下来,以便在需要时可以翻阅。

[En]

These two are used too frequently in daily programming, so it is more or less necessary to record them so that they can be flipped through when needed.

但是,考虑到他们的后代太多,要一一记住有点困难,所以我们在学习中要把握好以下几点:

[En]

However, in view of the fact that they have too many offspring, it is a bit difficult to remember them one by one, so we should grasp the following points in learning:

在日常工作中,应当在思考设计目的的基础上选择需要的实现类,例如是考虑效率还是线程安全,是要求FIFO还是FILO。

如果你知道下面要用哪一个,那就用它,否则就去找参考资料。参考文献可以是专业书籍、权威网站或博客。

[En]

If you know which one to use below, use it, otherwise look for resources. References can be professional books, authoritative websites or blogs.

一、基本概念以及集合和映射的区别

1.1 Collection-集合

用于保存多个对象的对象。本质上,数组用于存储每个元素,每个元素不必具有相同的类型,也不需要以有序的方式存储。

[En]

An object used to save several objects. In essence, arrays are used to store each element, and each element does not have to be of the same type, nor is it required to be stored in an orderly manner.

数组通常只存储原始数据本身,而不存储对象的内容,这是与映射的主要区别。

[En]

Arrays usually store only the original itself, not the contents of the object, which is the main difference from mapping.

1.2 Map-映射

顾名思义,需要一个对象元素必须有两个对象对应:键和值,或者是key和value。

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长