Example
Retrieve the final item from the list.
|
|
Definition and Usage
The getLast() method retrieves the last item in a list.
Tip: Employ the getFirst() method to obtain the first item in a list.
Syntax
| public T getLast() |
T signifies the data type of elements in the list.
Parameters
None.
Technical Details
|
Returns: |
The final element in the list |
|
Throws: |
NoSuchElementException occurs if the list is empty. |