Difference between Arrays and 3 dots (Varargs) in java

后端 未结 3 786
栀梦
栀梦 2020-12-07 13:27

I cannot figure out that what are the differences between ... in java and arrays also array list, especially array list.

Both we can use as unlimited bu

3条回答
  •  悲&欢浪女
    2020-12-07 13:54

    • An array is a fixed length collection of objects. e.g. new int[5];
    • An ArrayList is a variable length collection of objects. e.g. new ArrayList();
    • The ... in variadic functions is a part of a method signature denoting an array of parameters. e.g. public void printLines(String... lines)

提交回复
热议问题