If you look at the List interface,
E e = list.get(list.size() - 1);
You can do it in this way. E is the type of list element. If the list is empty, throw an IndexOutOfBoundsException error in the get method.
If you want to view the full API documentation, you can http://docs.oracle.com/javase/6/docs/api/
© 2024 OneMinuteCode. All rights reserved.