Set 和 List 有什么区别? [英] What is the difference between Set and List?

查看:41
本文介绍了Set 和 List 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SetList 接口之间的根本区别是什么?

What is the fundamental difference between the Set<E> and List<E> interfaces?

推荐答案

List 是一个有序的元素序列,而 Set 是一个不同的元素列表,它是无序的(谢谢,奎因·泰勒).

List is an ordered sequence of elements whereas Set is a distinct list of elements which is unordered (thank you, Quinn Taylor).

List:

有序集合(也称为序列).此界面的用户可以精确控制在什么地方列出每个插入的元素.这用户可以通过他们的访问元素整数索引(列表中的位置),并搜索列表中的元素.

An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.

Set:

一个不包含任何内容的集合重复元素.更正式地说,集合不包含元素对 e1和 e2 使得 e1.equals(e2),并且在最多一个空元素.正如所暗示的那样它的名字,这个接口模拟数学集合抽象.

A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.

这篇关于Set 和 List 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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