This example will show how to remove the last object from an arraylist in java. A similar example shows how to remove the last element from an array.
@Test public void drop_last_element_java() { List<String> lastElementRemoved = new ArrayList<String>(); lastElementRemoved.add("one"); lastElementRemoved.add("two"); lastElementRemoved.add("three"); lastElementRemoved.remove(lastElementRemoved.size() - 1); assertEquals(2, lastElementRemoved.size()); }