On a previous project I was required to read file contents into an array. Now I have to do the same thing only I have to read the contents into an ArrayList. A few problems I
Instead of assigning the line to array[i], simply do arrayList.add(line)
array[i]
arrayList.add(line)
If this is not homework, consider using some 3rd party utilities like apache-commons FileUtils.readLines(..) or guava Files.readLines(..)
FileUtils.readLines(..)
Files.readLines(..)