Use ArrayLists initialised to the right size. Do not initialize the result at all here (it is assigned again below without being used in between)