![]() |
VOOZH | about |
Stack.lastElement()Parameters: The method does not take any parameter. Return Value: The method returns the last element present in the Stack. Below programs illustrate the Java.util.Stack.lastElement() method: Program 1:
Stack: [Welcome, To, Geeks, 4, Geeks] The last element is: Geeks
Stack: [10, 15, 30, 20, 5] The last element is: 5