java.util
Class Collections.CopiesList

java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
java.util.Collections.CopiesList
- All Implemented Interfaces:
- Collection, java.lang.Iterable, List, RandomAccess, java.io.Serializable
- Enclosing class:
- Collections
- private static final class Collections.CopiesList
- extends AbstractList
- implements java.io.Serializable, RandomAccess
The implementation of Collections.nCopies(int, 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, hashCode, iterator, listIterator, listIterator, remove, removeRange, set |
| Methods inherited from class java.util.AbstractCollection |
addAll, containsAll, equals, hashCode, isEmpty, remove, removeAll, removeAllInternal, retainAll, retainAllInternal, toArray |
serialVersionUID
private static final long serialVersionUID
- Compatible with JDK 1.4.
- See Also:
- Constant Field Values
n
private final int n
- The count of elements in this list.
element
private final java.lang.Object element
- The repeated list element.
Collections.CopiesList
Collections.CopiesList(int n,
java.lang.Object o)
- Constructs the list.
size
public int size()
- The size is fixed.
- Specified by:
size in interface List- Specified by:
size in class AbstractCollection
get
public java.lang.Object get(int index)
- The same element is returned.
- Specified by:
get in interface List- Specified by:
get in class AbstractList
contains
public boolean contains(java.lang.Object o)
- This list only contains one element.
- Specified by:
contains in interface List- Overrides:
contains in class AbstractCollection
indexOf
public int indexOf(java.lang.Object o)
- The index is either 0 or -1.
- Specified by:
indexOf in interface List- Overrides:
indexOf in class AbstractList
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- The index is either n-1 or -1.
- Specified by:
lastIndexOf in interface List- Overrides:
lastIndexOf in class AbstractList
subList
public List subList(int from,
int to)
- A subList is just another CopiesList.
- Specified by:
subList in interface List- Overrides:
subList in class AbstractList
toArray
public java.lang.Object[] toArray()
- The array is easy.
- Specified by:
toArray in interface List- Overrides:
toArray in class AbstractCollection
toString
public java.lang.String toString()
- The string is easy to generate.
- Overrides:
toString in class AbstractCollection