-3

What is the difference in adding the [] to an ArrayList a, as opposed to initializing like ArrayList b? Is there any purpose for one way or the other?

ArrayList<Integer> a[];
ArrayList<Integer> b;

2 Answers2

1

ArrayList<Integer> b; is declaring a reference to an array list that contains integers, named b. ArrayList<Integer> a[]; is declaring a reference to an array of array lists that contain integers, named a.

ArrayList<Integer> a[] is the same as ArrayList<Integer>[] a.

Luke Joshua Park
  • 8,659
  • 5
  • 22
  • 41
0

One is list of integers Another is array of list of integers