Effective Java | Item 44 | Favor the use of standard functional interfaces

Опубликовано: 09 Апрель 2026
на канале: Omkar Shetkar
174
2

If one of the standard functional interfaces does the job, you should generally use it in preference to a purpose-built functional interface.
Don't be tempted to use basic functional interfaces with boxed primitives instead of primitive functional interfaces.
You should prefer to write custom functional interface in preference to using a standard one only if
It will be commonly used and could benefit from a descriptive name.
It has a strong contract associated with it.
It would benefit from custom default methods.
Always annotate your functional interfaces with the @FunctionalInterface annotation.
Do not provide a method with multiple overloadings that take different functional interfaces in the same argument position if it could create a possible ambiguity in the client.


GitHub: https://github.com/Omkar-Shetkar/effe...