Category: Constructor References

Using the forEach() Method to Iterate Over a Collection – Collections: Part IIUsing the forEach() Method to Iterate Over a Collection – Collections: Part II

Using the forEach() Method to Iterate Over a Collection The default method forEach() of the Iterable<E> interface (which the Collection<E> interface implements) allows us to do away with an explicit [...]

Implementing the java.util.Comparator Interface – Object ComparisonImplementing the java.util.Comparator Interface – Object Comparison

14.5 Implementing the java.util.Comparator<E> Interface The java.util.Comparator<E> interface is a functional interface and is designated as such with the @FunctionalInterface annotation in the Java SE API documentation— in other words, [...]

Implementing the java.util.Comparator Interface 2 – Object ComparisonImplementing the java.util.Comparator Interface 2 – Object Comparison

The String class implements the Comparable<E> interface, providing an implementation of the compareTo() method. The compareTo() method defines the natural ordering for strings, which is lexicographical. The natural ordering is [...]