Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Java

Idiom #226 Delete last element from list

Remove the last element from the list items.

import static java.util.Arrays.copyOfRange;
items = copyOfRange(items, 0, items.length - 1);
import static java.lang.System.arraycopy;
int n, t[] = new int[n = items.length - 1];
arraycopy(items, 0, t, 0, n);
items = t;
items.removeLast();
import java.util.List;
items.remove(items.size() - 1);
with Ada.Containers.Vectors;
Items.Delete_Last (Count => 1);

New implementation...
< >
programming-idioms.org