boolean hasNext()E next()void remove() (optional)private final class ListIterator implements Iterator<T> {
private Element current;
private ListIterator() { current = head; }
public boolean hasNext() { return current.next != null; }
public T next() {
if (hasNext()) {
current = current.next;
return current.value;
} else throw new NoSuchElementException();
}
public void remove() { throw new UnsupportedOperationException(); }
}
Iterablepublic interface Iterable<T> {
/**
* Returns an iterator over a set of elements of type T.
* @return an Iterator.
*/
Iterator<T> iterator();
}
interface Collection<E>Iterableboolean add(E)boolean remove(Object)boolean contains(E)int size()interface List<E>Collectionboolean get(int)boolean set(int, E)boolean add(int, E)boolean remove(int)int indexOf(Object)ArrayList, LinkedList, …interface Set<E>CollectionSet => HashSet, EnumSetSortedSet => TreeSetQueue und DequeQueue
LinkedList, PriorityQueue, …Deque
QueueLinkedList, ArrayDeque, …interface Map<K,V>key verweist auf ein valuekey und value eingefügtkeysMap => HashMap, LinkedHashMap (Zugriff in O(1))SortedMap => TreeMap (Zugriff in O(log n))class Collectionsvoid reverse(List<?> list)
void shuffle(List<?> list)
T max(Collection<? extends T> coll)
boolean disjoint(Collection<?> c1, Collection<?> c2)
Collection<T> unmodifiableCollection(Collection<? extends T> c)
class Arraysvoid sort(Object[] a)
void fill(Object[] a, Object val)
List<T> asList(T... a)
int binarySearch(T[] a, T key, Comparator<? super T> c)
Write a method that takes a string and returns the number of unique characters in the string.
The method should cache the results, so that when the method is given a string previously encountered, it will simply retrieve the stored result.
