The command
input = sc.nextLine().split(" ");
does not fill the existing array (referenced by input
) with data.
It creates a new array and assigns a reference to it to input
.
Whatever input
was pointing to becomes dereferenced and a subject to garbage collection.