The only thing I can see wrong for sure is that Java's arrays start with index 0, not 1.


for(i = 0; i < messages.length; i++)