Grokking Java Interview Questions
0% completed
Method References and Variable Capture
| Method reference | Lambda with the same result |
|---|---|
Integer::parseInt | text -> Integer.parseInt(text) |
stock::get | name -> stock.get(name) |
String::length | text -> text.length() |
ArrayList::new | () -> new ArrayList<>() |
A method reference is a short form for a lambda that only calls one existing method or constructor. The four rows look alike on the left, although each one supplies the arguments of the call in a different way.
The first question below names the four kinds
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%