public class SingletonList
extends java.util.AbstractList
add()
and remove()
throw
UnsupportedOperationExceptions.Modifier and Type | Field and Description |
---|---|
private java.lang.Object |
element |
Constructor and Description |
---|
SingletonList(java.lang.Object element)
Creates a new singleton list.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(int index)
Returns the single element in the list.
|
int |
size()
Returns 1.
|
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public SingletonList(java.lang.Object element)
element
- the single member of the listpublic int size()
size
in interface java.util.Collection
size
in interface java.util.List
size
in class java.util.AbstractCollection
public java.lang.Object get(int index)
get
in interface java.util.List
get
in class java.util.AbstractList
java.lang.IndexOutOfBoundsException
- if index is not 0