Use Type Inference for Parameters
Traditionally, in Java we’re used to specifying the types of parameters. Starting with version 8, the language has been leaning more toward type inference. The Java compiler is smart enough to determine the type of the lambda expression parameters in most situations. That means less typing on the keyboard but without compromising type safety in code.
Many programmers who’ve been coding in Java for a long time, and especially those who mostly don’t program in other languages as well, are often reluctant to use type inference. They feel comfortable when the types of the lambda expression parameters are specified and get frustrated reading code where the types aren’t specified.
You can leverage the type inference ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access