Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the name of a list with only one element

Tags:

java

list

What is the 'formal' name of a list that has only one element?

like image 990
user1508893 Avatar asked Jul 27 '12 22:07

user1508893


2 Answers

Java Collections calls this a singleton list, although I don't think this is a formal name.

public static List singletonList(T o) Returns an immutable list containing only the specified object. The returned list is serializable.

I much prefer "single element list".

Edit: It appears that singleton is a valid mathematical term for a single element set.

like image 127
Steve Kuo Avatar answered Sep 19 '22 02:09

Steve Kuo


I would call it a unitList (to avoid confusion with the Singleton pattern) in mathematics a set containing only a single element is also known as a unit set

like image 38
munyengm Avatar answered Sep 22 '22 02:09

munyengm