Schrödinger's Cat
$$i\hbar{\partial\Psi\over \partial t} = -{\hbar^2\over 2m} \nabla^2\Psi + V\Psi.$$
Java has a Schrödinger's Cat: Optonal<T>
This represents an object that might or might not be present.
Friends These are the primitive "friend" types
for Optional<T>
OptionalInt
OptionalDouble
OptionalLong
More About Streams
Sources
- Collections, using
stream()
- Arrays, using
Arrays.stream()
BufferedReaders
, usinglines()
String
, usingchars()
yields anIntStream
Intermediate Operations All of these return streams. They are chainable.
Terminal Operations Purportedly, you want to do something with the stream you generate. In fact, nothing happens until one of these operations is invoked.
count()
Counts the items in the stream.sum()
Sum the items in a numerical stream.boolean allMatch(Predicate<? super T>)
Returnstrue
if all items match the predicate.boolean anyMatch(Predicate<? super T>)
Returnstrue
if any of the items match the predicate.Optional<T> findAny(Predicate<T>)
Returns anOptional
containing some elemenet for which the the predicate is true, and returns and emptyOptional
otherwise.Optional<T> findFirst(Predicate<T>)
Returns anOptional
containing the first elemenet for which the the predicate is true, and returns and emptyOptional
otherwise.