Skip to content

Instantly share code, notes, and snippets.

@HoweChen
Created September 25, 2019 09:46
Show Gist options
  • Select an option

  • Save HoweChen/f7af95ccd3afdf368b9c8340ef57f599 to your computer and use it in GitHub Desktop.

Select an option

Save HoweChen/f7af95ccd3afdf368b9c8340ef57f599 to your computer and use it in GitHub Desktop.
[ArrayList初始化] #Java
// traditional method
ArrayList<String> list = new ArrayList<String>();
list.add("A");
list.add("B");
list.add("C");
// one-line method
ArrayList<String> list = new ArrayList<>(Arrays.asList("A","B","C"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment