T
- Generic type parameter.public interface MyList<T>
extends java.lang.Iterable<T>
Modifier and Type | Method and Description |
---|---|
void |
add(int i,
T item)
Add (insert) item to the ith position of this MyList.
|
void |
add(T item)
Add item to the end of this List.
|
T |
get(int i)
Get the element at index i
|
int |
indexOf(java.lang.Object item)
Find the index of the input item in this MyList.
|
T |
remove(int i)
Remove the item at the ith position from this MyArrayList.
|
T |
set(int i,
T item)
Replace the element at i with new one provided by the parameter item.
|
int |
size() |
java.lang.Object[] |
toArray()
This method return an Object array of the same size that contains every element
in this MyList;
|
<K> K[] |
toArray(K[] a)
Returns an array that contains every element in this MyList.
|
java.lang.String |
toString()
Override toString method so it will return a String started and ended by [ and ],
respectively, in which all elements' results of their own toString() will be
concatenated according to their order in the list.
|
int size()
T get(int i)
i
- is an int.java.lang.IndexOutOfBoundsException
- will be thrown if parameter i is not a
legitimate index.T set(int i, T item)
i
- is an int.item
- is a T.java.lang.IndexOutOfBoundsException
- will be thrown if parameter i is not a
legitimate index.int indexOf(java.lang.Object item)
item
- is an Object.void add(T item)
item
- is a T.void add(int i, T item)
i
- is an int.item
- is a T.java.lang.IndexOutOfBoundsException
- will be thrown if parameter i is not a
legitimate index.T remove(int i)
i
- is an int.java.lang.IndexOutOfBoundsException
- will be thrown if parameter i is not a
legitimate index.java.lang.Object[] toArray()
<K> K[] toArray(K[] a)
K
- is any typea
- is the specific array to receive the elementjava.lang.NullPointerException
- will be thrown, if the specified array is null.java.lang.String toString()
toString
in class java.lang.Object