Created
September 25, 2019 09:46
-
-
Save HoweChen/f7af95ccd3afdf368b9c8340ef57f599 to your computer and use it in GitHub Desktop.
[ArrayList初始化] #Java
This file contains hidden or 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
| // 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