java.util
Class Collections.SingletonList

java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
java.util.Collections.SingletonList
- All Implemented Interfaces:
- Collection, java.lang.Iterable, List, RandomAccess, java.io.Serializable
- Enclosing class:
- Collections
- private static final class Collections.SingletonList
- extends AbstractList
- implements java.io.Serializable, RandomAccess
The implementation of Collections.singletonList(Object) 55 . This class name
is required for compatibility with Sun's JDK serializability.
| Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, equals, iterator, listIterator, listIterator, remove, removeRange, set |
serialVersionUID
private static final long serialVersionUID
- Compatible with JDK 1.4.
- See Also:
- Constant Field Values
element
private final java.lang.Object element
- The single element.
Collections.SingletonList
Collections.SingletonList(java.lang.Object o)
- Construct a singleton.
size
public int size()
- The size: always 1!
- Specified by:
size in interface List- Specified by:
size in class AbstractCollection
get
public java.lang.Object get(int index)
- Only index 0 is valid.
- Specified by:
get in interface List- Specified by:
get in class AbstractList
contains
public boolean contains(java.lang.Object o)
- The set only contains one element.
- Specified by:
contains in interface List- Overrides:
contains in class AbstractCollection
containsAll
public boolean containsAll(Collection c)
- This is true if the other collection only contains the element.
- Specified by:
containsAll in interface List- Overrides:
containsAll in class AbstractCollection
hashCode
public int hashCode()
- Speed up the hashcode computation.
- Specified by:
hashCode in interface List- Overrides:
hashCode in class AbstractList
indexOf
public int indexOf(java.lang.Object o)
- Either the list has it or not.
- Specified by:
indexOf in interface List- Overrides:
indexOf in class AbstractList
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Either the list has it or not.
- Specified by:
lastIndexOf in interface List- Overrides:
lastIndexOf in class AbstractList
subList
public List subList(int from,
int to)
- Sublists are limited in scope.
- Specified by:
subList in interface List- Overrides:
subList in class AbstractList
toArray
public java.lang.Object[] toArray()
- Returning an array is simple.
- Specified by:
toArray in interface List- Overrides:
toArray in class AbstractCollection
toString
public java.lang.String toString()
- Obvious string.
- Overrides:
toString in class AbstractCollection