Substitute an item in a list.
import public
}
|
Definition and Usage
The set() method exchanges an item at a designated position in the list and returns the item that previously occupied that position.
Syntax
public T set(int index, T item) |
T represents the data type of items within the list.
Parameter Values
Parameter |
Description |
index |
Mandatory. The index of the item to be substituted. |
Item |
Mandatory. The new item to replace the one at the specified position. |
Technical Details
Returns: |
The item that previously occupied the designated position in the list. |
Throws: |
IndexOutOfBoundsException occurs if the index is less than zero, equal to the size of the list, or greater than the size of the list. |