Functional Interfaces in Java
An interface with exactly one abstract method can be implemented by a lambda, and the standard library supplies the ones you need most.
Material for readers past the basics.
145 notes tagged
An interface with exactly one abstract method can be implemented by a lambda, and the standard library supplies the ones you need most.
A lambda is a short way to write an implementation of a single method interface, so behaviour can be passed around like a value.
Generics let a class or method work with a type supplied by the caller, moving whole families of errors from runtime to compile time.
The helper methods that save writing loops, and a practical way to pick the right collection every time.
Comparable gives a class one natural order. Comparator supplies any number of orders from outside, without touching the class.
An Iterator walks a collection one element at a time, and it is the only safe way to remove during a traversal.
A Queue processes elements in an order it decides. A Deque works at both ends, and it is the right way to build a stack in Java.
The rules that separate exception handling which helps from exception handling which hides bugs.
A custom exception names a failure in the language of your domain, which makes handling precise and messages meaningful.
Wrapper classes turn primitives into objects so they can be used with generics and collections, and the conversion is automatic but not free.
An annotation attaches metadata to code. It changes nothing by itself; a compiler, a tool or a framework reads it and acts.
A record declares an immutable data carrier, and the compiler generates the constructor, accessors, equals, hashCode and toString.