巴扎黑2017-04-17 17:51:04
If you want to create an ArrayList array, you can write it like this
ArrayList<Integer>[] array = new ArrayList[3];
System.out.println(array.length);
伊谢尔伦2017-04-17 17:51:04
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.
ringa_lee2017-04-17 17:51:04
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.
ArrayList<Integer> g = new ArrayList<Integer>(0);
天蓬老师2017-04-17 17:51:04
ArrayList<Integer>[] array = new ArrayList<Integer>[Integer.MAX_VALUE];