List
An ordered list, such as the one InventoryAPI.getItems() returns.
InterfaceJavaJava 11 docs
public interface List<E> extends Collection<E>Loop over it with for (ItemEx item : items). The lists the API gives you are copies. Make your own with new ArrayList<>().
Example
List<ItemEx> items = InventoryAPI.getItems();
if (!items.isEmpty()) {
ItemEx first = items.get(0);
}Members
Methods
- Eget(int)
The element at a position.
- booleanisEmpty()
Whether the list has no elements.
- Iterator<E>iterator()
Walks over the elements. A
forloop does this for you. - intsize()
The number of elements.
get(int)
public E get(int index)The element at a position.
Parameters
index- The position, counting from
0.
Returns
The element.
isEmpty()
public boolean isEmpty()Whether the list has no elements.
Returns
true if it is empty.
iterator()
public Iterator<E> iterator()Walks over the elements. A for loop does this for you.
Returns
An Iterator.
size()
public int size()The number of elements.
Returns
The size.
Also allowed
These work as in the Java 11 docs.
add, addAll, clear, contains, containsAll, copyOf, equals, forEach, hashCode, indexOf, lastIndexOf, listIterator, of, remove, removeAll, removeIf, replaceAll, retainAll, set, sort, stream, subList, toArray, toString