It’s unclear what the problem is but your for loop doesnt over the letters in word
as the termination condition is based on the empty List
size passed to the buildAL
method. Replace
for (int i = 0; i < arr2.size(); i++)
with
for (int i = 0; i < word.length(); i++) {
solved Error in program [closed]