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, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringpublic SingletonList(java.lang.Object element)
element - the single member of the listpublic int size()
size in interface java.util.Collectionsize in interface java.util.Listsize in class java.util.AbstractCollectionpublic java.lang.Object get(int index)
get in interface java.util.Listget in class java.util.AbstractListjava.lang.IndexOutOfBoundsException - if index is not 0