java.util
Class Collections.SingletonSet

java.lang.Object
java.util.AbstractCollection
java.util.AbstractSet
java.util.Collections.SingletonSet
- All Implemented Interfaces:
- Collection, java.lang.Iterable, java.io.Serializable, Set
- Enclosing class:
- Collections
- private static final class Collections.SingletonSet
- extends AbstractSet
- implements java.io.Serializable
The implementation of Collections.singleton(Object) 55 . This class name
is required for compatibility with Sun's JDK serializability.
| Methods inherited from class java.util.AbstractCollection |
add, addAll, clear, equals, hashCode, isEmpty, remove, removeAllInternal, retainAll, retainAllInternal, toArray |
serialVersionUID
private static final long serialVersionUID
- Compatible with JDK 1.4.
- See Also:
- Constant Field Values
element
final java.lang.Object element
- The single element; package visible for use in nested class.
Collections.SingletonSet
Collections.SingletonSet(java.lang.Object o)
- Construct a singleton.
size
public int size()
- The size: always 1!
- Specified by:
size in interface Set- Specified by:
size in class AbstractCollection
iterator
public Iterator iterator()
- Returns an iterator over the lone element.
- Specified by:
iterator in interface Set- Specified by:
iterator in class AbstractCollection
contains
public boolean contains(java.lang.Object o)
- The set only contains one element.
- Specified by:
contains in interface Set- 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 Set- Overrides:
containsAll in class AbstractCollection
hashCode
public int hashCode()
- The hash is just that of the element.
- Specified by:
hashCode in interface Set- Overrides:
hashCode in class AbstractSet
toArray
public java.lang.Object[] toArray()
- Returning an array is simple.
- Specified by:
toArray in interface Set- Overrides:
toArray in class AbstractCollection
toString
public java.lang.String toString()
- Obvious string.
- Overrides:
toString in class AbstractCollection