Add multiple items to already initialized arraylist in java

前端 未结 6 1708
温柔的废话
温柔的废话 2020-11-27 16:45

I\'m googling it and can\'t seem to find the syntax. My arraylist might be populated differently based on a user setting, so I\'ve initialized it



        
6条回答
  •  星月不相逢
    2020-11-27 17:10

    What is the "source" of those integer? If it is something that you need to hard code in your source code, you may do

    arList.addAll(Arrays.asList(1,1,2,3,5,8,13,21));
    

提交回复
热议问题