Java Standard Library

Author: Jacob Park

Java™ Platform, Standard Edition 8 API Specification

  • ArrayDeque
    • offer(E e) - Inserts the specified element at the end of this deque.
    • poll() - Retrieves and removes the head of the queue represented by this deque.
    • peekFirst() - Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.
    • push(E e) - Pushes an element onto the stack represented by this deque.
    • pop() - Pops an element from the stack represented by this deque.
    • peekLast() - Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.
  • ArrayList
    • add(E e) - Appends the specified element to the end of this list.
    • add(int index, E element) - Inserts the specified element at the specified position in this list.
    • get(int index) - Returns the element at the specified position in this list.
    • remove(int index) - Removes the element at the specified position in this list.
    • set(int index, E element) - Replaces the element at the specified position in this list with the specified element.
    • subList(int fromIndex, int toIndex) - Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
  • Arrays
    • asList(T... a) - Returns a fixed-size list backed by the specified array.
    • binarySearch(int[] a, int key) - Searches the specified array of ints for the specified value using the binary search algorithm.
    • binarySearch(int[] a, int fromIndex, int toIndex, int key) - Searches a range of the specified array of ints for the specified value using the binary search algorithm.
    • copyOf(int[] original, int newLength) - Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.
    • copyOfRange(int[] original, int from, int to) - Copies the specified range of the specified array into a new array.
    • equals(int[] a, int[] a2) - Returns true if the two specified arrays of ints are equal to one another.
    • fill(int[] a, int val) - Assigns the specified int value to each element of the specified array of ints.
    • fill(int[] a, int fromIndex, int toIndex, int val) - Assigns the specified int value to each element of the specified range of the specified array of ints.
    • hashCode(int[] a) - Returns a hash code based on the contents of the specified array.
    • sort(int[] a) - Sorts the specified array into ascending numerical order.
    • sort(int[] a, int fromIndex, int toIndex) - Sorts the specified range of the array into ascending order.
    • toString(int[] a) - Returns a string representation of the contents of the specified array.
  • BigInteger
    • gcd(BigInteger val) - Returns a BigInteger whose value is the greatest common divisor of abs(this) and abs(val).
    • isProbablePrime(int certainty) - Returns true if this BigInteger is probably prime, false if it's definitely composite.
    • nextProbablePrime() - Returns the first integer greater than this BigInteger that is probably prime.
  • BitSet
    • cardinality() - Returns the number of bits set to true in this BitSet.
    • clear(int bitIndex) - Sets the bit specified by the index to false.
    • flip(int bitIndex) - Sets the bit at the specified index to the complement of its current value.
    • get(int bitIndex) - Returns the value of the bit with the specified index.
    • nextClearBit(int fromIndex) - Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
    • nextSetBit(int fromIndex) - Returns the index of the first bit that is set to true that occurs on or after the specified starting index.
    • previousClearBit(int fromIndex) - Returns the index of the nearest bit that is set to false that occurs on or before the specified starting index.
    • previousSetBit(int fromIndex) - Returns the index of the nearest bit that is set to true that occurs on or before the specified starting index.
    • set(int bitIndex) - Sets the bit at the specified index to true.
  • Collections
    • binarySearch(List<? extends Comparable<? super T>> list, T key) - Searches the specified list for the specified object using the binary search algorithm.
    • copy(List<? super T> dest, List<? extends T> src) - Copies all of the elements from one list into another.
    • disjoint(Collection<?> c1, Collection<?> c2) - Returns true if the two specified collections have no elements in common.
    • fill(List<? super T> list, T obj) - Replaces all of the elements of the specified list with the specified element.
    • frequency(Collection<?> c, Object o) - Returns the number of elements in the specified collection equal to the specified object.
    • indexOfSubList(List<?> source, List<?> target) - Returns the starting position of the first occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence.
    • lastIndexOfSubList(List<?> source, List<?> target) - Returns the starting position of the last occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence.
    • max(Collection<? extends T> coll, Comparator<? super T> comp) - Returns the maximum element of the given collection, according to the order induced by the specified comparator.
    • min(Collection<? extends T> coll, Comparator<? super T> comp) - Returns the minimum element of the given collection, according to the order induced by the specified comparator.
    • reverse(List<?> list) - Reverses the order of the elements in the specified list.
    • rotate(List<?> list, int distance)- Rotates the elements in the specified list by the specified distance.
    • shuffle(List<?> list) - Randomly permutes the specified list using a default source of randomness.
    • sort(List<T> list, Comparator<? super T> c) - Sorts the specified list according to the order induced by the specified comparator.
    • swap(List<?> list, int i, int j) - Swaps the elements at the specified positions in the specified list.
  • DoubleSummaryStatistics
    • accept(double value) - Records another value into the summary information.
    • combine(DoubleSummaryStatistics other) - Combines the state of another DoubleSummaryStatistics into this one.
    • getAverage() - Returns the arithmetic mean of values recorded, or zero if no values have been recorded.
    • getCount() - Return the count of values recorded.
    • getMax() - Returns the maximum recorded value, Double.NaN if any recorded value was NaN or Double.NEGATIVE_INFINITY if no values were recorded.
    • getMin() - Returns the minimum recorded value, Double.NaN if any recorded value was NaN or Double.POSITIVE_INFINITY if no values were recorded.
    • getSum() - Returns the sum of values recorded, or zero if no values have been recorded.
  • HashMap
    • containsKey(Object key) - Returns true if this map contains a mapping for the specified key.
    • get(Object key) - Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
    • put(K key, V value) - Associates the specified value with the specified key in this map.
    • remove(Object key) - Removes the mapping for the specified key from this map if present.
  • HashSet
    • add(E e) - Adds the specified element to this set if it is not already present.
    • addAll(Collection<? extends E> c) - Adds all of the elements in the specified collection to this set if they're not already present.
    • contains(Object o) - Returns true if this set contains the specified element.
    • containsAll(Collection<?> c) - Returns true if this set contains all of the elements of the specified collection.
    • remove(Object o) - Removes the specified element from this set if it is present.
    • removeAll(Collection<?> c) - Removes from this set all of its elements that are contained in the specified collection.
    • retainAll(Collection<?> c) - Retains only the elements in this set that are contained in the specified collection.
    • size() - Returns the number of elements in this set (its cardinality).
  • LinkedList
    • addFirst(E e) - Inserts the specified element at the beginning of this list.
    • addLast(E e) - Appends the specified element to the end of this list.
    • getFirst() - Returns the first element in this list.
    • getLast() - Returns the last element in this list.
    • removeFirst() - Removes and returns the first element from this list.
    • removeLast() - Removes and returns the last element from this list.
    • descendingIterator() - Returns an iterator over the elements in this deque in reverse sequential order.
    • iterator() - Returns an iterator over elements of type T.
  • Math
    • abs(double a) - Returns the absolute value of a double value.
    • ceil(double a) - Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.
    • floor(double a) - Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.
    • max(double a, double b) - Returns the greater of two double values.
    • min(double a, double b) - Returns the smaller of two double values.
    • random() - Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
    • round(double a) - Returns the closest long to the argument, with ties rounding to positive infinity.
    • signum(double d) - Returns the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.
  • Objects
    • compare(T a, T b, Comparator<? super T> c) - Returns 0 if the arguments are identical and c.compare(a, b) otherwise.
    • deepEquals(Object a, Object b) - Returns true if the arguments are deeply equal to each other and false otherwise.
    • equals(Object a, Object b) - Returns true if the arguments are equal to each other and false otherwise.
    • hash(Object... values) - Generates a hash code for a sequence of input values.
  • PriorityQueue
    • offer(E e) - Inserts the specified element into this priority queue.
    • peek() - Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
    • poll() - Retrieves and removes the head of this queue, or returns null if this queue is empty.
  • Scanner
    • findInLine(String pattern) - Attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.
    • hasNext(String pattern) - Returns true if the next token matches the pattern constructed from the specified string.
    • next(String pattern) - Returns the next token if it matches the pattern constructed from the specified string.
    • skip(String pattern) - Skips input that matches a pattern constructed from the specified string.
    • useDelimiter(String pattern) - Sets this scanner's delimiting pattern to a pattern constructed from the specified string.
  • Stack
    • peek() - Looks at the object at the top of this stack without removing it from the stack.
    • pop() - Removes the object at the top of this stack and returns that object as the value of this function.
    • push(E item) - Pushes an item onto the top of this stack.
  • StringBuffer
    • append(CharSequence s) - Appends the specified CharSequence to this character sequence.
    • delete(int start, int end) - Removes the characters in a substring of this sequence.
    • indexOf(String str, int fromIndex) - Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
    • insert(int dstOffset, CharSequence s, int start, int end) - Inserts a subsequence of the specified CharSequence into this sequence.
    • reverse() - Causes this character sequence to be replaced by the reverse of the sequence.
    • substring(int start, int end) - Returns a new string that contains a subsequence of characters currently contained in this sequence.
    • toString() - Returns a string representing the data in this sequence.
  • TreeMap
    • containsKey(Object key) - Returns true if this map contains a mapping for the specified key.
    • get(Object key) - Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
    • put(K key, V value) - Associates the specified value with the specified key in this map.
    • remove(Object key) - Removes the mapping for the specified key from this map if present.
    • ceilingEntry(K key) - Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.
    • floorEntry(K key) - Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
    • firstEntry() - Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
    • lastEntry() - Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
    • higherEntry(K key) - Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.
    • lowerEntry(K key) - Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.
    • headMap(K toKey, boolean inclusive) - Returns a view of the portion of this map whose keys are less than (or equal to, if inclusive is true) toKey.
    • tailMap(K fromKey, boolean inclusive) - Returns a view of the portion of this map whose keys are greater than (or equal to, if inclusive is true) fromKey.
    • subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) - Returns a view of the portion of this map whose keys range from fromKey to toKey.
  • TreeSet
    • add(E e) - Adds the specified element to this set if it is not already present.
    • addAll(Collection<? extends E> c) - Adds all of the elements in the specified collection to this set if they're not already present.
    • contains(Object o) - Returns true if this set contains the specified element.
    • containsAll(Collection<?> c) - Returns true if this set contains all of the elements of the specified collection.
    • remove(Object o) - Removes the specified element from this set if it is present.
    • removeAll(Collection<?> c) - Removes from this set all of its elements that are contained in the specified collection.
    • retainAll(Collection<?> c) - Retains only the elements in this set that are contained in the specified collection.
    • size() - Returns the number of elements in this set (its cardinality).
    • ceiling(E e) - Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
    • floor(E e) - Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
    • first() - Returns the first (lowest) element currently in this set.
    • last() - Returns the last (highest) element currently in this set.
    • higher(E e) - Returns the least element in this set strictly greater than the given element, or null if there is no such element.
    • lower(E e) - Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
    • headSet(E toElement, boolean inclusive) - Returns a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement.
    • tailSet(E fromElement, boolean inclusive) - Returns a view of the portion of this set whose elements are greater than (or equal to, if inclusive is true) fromElement.
    • subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) - Returns a view of the portion of this set whose elements range from fromElement to toElement.
In [1]:
import java.lang.Math;
import java.util.*;
import java.util.Arrays.*;
import java.util.Collections.*;
Out[1]:
null
In [2]:
import java.util.*;

final Scanner scanner = new Scanner(System.in);
Out[2]:
null
In [3]:
import java.util.*;

System.out.println(String.format("Hello %s! It's %d!", "Jacob", 2018));
Hello Jacob! It's 2018!
Out[3]:
null