This example will show how to remove the last object from an array in java. A similar example shows how to remove the last element from a collection.
Straight up Java
private static final Logger logger = Logger
.getLogger(RemoveElementFromArray.class);
@Test
public void drop_last_element_java() {
String[] lastElementRemoved = { "one", "two", "three" };
String[] removedElement = Arrays.copyOf(lastElementRemoved, 2);
logger.info(Arrays.toString(removedElement));
assertEquals(2, removedElement.length);
}
Output
[one, two]