Skip to content

Instantly share code, notes, and snippets.

@herdianf
Created August 24, 2018 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herdianf/53c8678c1d14d4f547996602c8661dbd to your computer and use it in GitHub Desktop.
Save herdianf/53c8678c1d14d4f547996602c8661dbd to your computer and use it in GitHub Desktop.
Create a Map with just one line
Object data = new Date();
Map<String,Object> map = Arrays.asList(new Object[][] {
{ "data", data },
{ "success", true }
}).stream().collect(Collectors.toMap(k -> (String)k[0], v -> v[1]))
@herdianf
Copy link
Author

NPE will throw for null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment