It's hard to know what's going on without the full code. And when you post code, please UseCodeTags (that's a link). I added them to your post above.
Is this from Head First Java? Be sure to quote your sources.
All things are lawful, but not all things are profitable.
posted 8 months ago
Does the MidiEvent constructor copy the contents of a or does it just copy the reference.
It is likely the call to setMessage will change a's contents to the current contents of i, losing the last contents.