I also suspect[]符号多加了,你应该不会是要一个list的数组。 那么,ArrayList<Integer> g = new ArrayList<Integer>();如果list的大小确认,可写成:ArrayList<Integer> g = new ArrayList<Integer>(size);Generally, there is no need to specify it. The performance impact is not significant and can be completely ignored.
Hello! It is recommended to learn more about Java. ArrayList is originally a collection. A collection can be seen as a dynamic array, so there is no need to add [] at the end.
If you want to create an ArrayList array, you can write it like this
I also suspect
[]
符号多加了,你应该不会是要一个list
的数组。那么,
ArrayList<Integer> g = new ArrayList<Integer>();
如果list
的大小确认,可写成:ArrayList<Integer> g = new ArrayList<Integer>(size);
Generally, there is no need to specify it. The performance impact is not significant and can be completely ignored.Hello! It is recommended to learn more about Java. ArrayList is originally a collection. A collection can be seen as a dynamic array, so there is no need to add [] at the end.