Created
April 26, 2017 15:09
-
-
Save wwarlock/31e4407ef02d6c2e5527fa326fecc929 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class ComputeIfAbsent { | |
public static void main(String[] args) { | |
Map map = new LinkedHashMap(); | |
map.computeIfAbsent(42, ArrayList::new); | |
} | |
} |
Of course, since there is no ArrayList with constructor taking an Object as parameter :-)
But as you said that is the correct answer.
Am I misunderstood something?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That code doesn't compile and gives the error
ComputeIfAbsent.java:7: error: incompatible types: invalid constructor reference