Optional in Java
Optional makes absence part of the type, so a caller cannot forget that a value might not be there.
Core Java, object oriented programming, collections, multithreading and JDBC.
100 notes in 18 topics
Optional makes absence part of the type, so a caller cannot forget that a value might not be there.
A stream describes a computation over a sequence of elements. You state what you want, and the pipeline decides how to walk the data.
filter, map, flatMap, sorted, distinct, limit, skip and peek. Each returns a new stream and none of them runs on its own.
A terminal operation runs the pipeline and produces a result, and reduce is the general purpose way to fold a stream into one value.
Collectors turn a stream into a collection, a map or a summary, and grouping is where they become genuinely powerful.
A parallel stream splits the work across threads. It helps less often than people expect, and it breaks silently when the rules are ignored.
The modern date and time API is immutable, thread safe and clearly named, and it replaced the older Date and Calendar classes entirely.
Instant marks a point on the timeline; Duration measures time based amounts and Period measures date based ones.
DateTimeFormatter converts between text and date time values, and ZoneId handles the region rules that make time zones difficult.
Path names a location and Files performs the operations. Together they replaced the older File class for almost every purpose.
InputStream and OutputStream carry raw bytes; Reader and Writer carry characters. Choosing wrongly corrupts data.
Every unbuffered read is a system call. Buffering turns thousands of them into a handful, and it is the single largest I/O win available.