Mich Robinson wrote:. . . Is there any performance cost in using arrays like this?
Performance is the last thing you should be worrying about. Get your code correct first: see whether there is a performance problem later.
You may find that the processing to work out the new location of your displayed text take 1μs or less (that is simply a guess). But it might take 10ms to repaint your display on screen (another guess), so you probably won't notice any performance issues. You will however notice performance issues if you are repainting too frequently. If you have several characters to move simultaneously, make sure all the movements are done before you call
repaint(). Otherwise there is a risk that you will take 10ms for your repainting and try repainting more than 100× per second, and your display will start to move with the speed of an arthritic snail.
Alternative answer: no, I don't think there will be any performance difference between what you wrote and using an object as Paul suggested.
or do I need to be more careful with garbage collection?
Another case, I think, where you are putting the cart before the horse. Remember the Java® runtime (=JVM) does its own garbage collection, and that is all automatic, so (to a first approximation) you simply forget about garbage collection in Java® code.
I know this might not look pretty . . .
I'm afraid you are right there. I agree with Paul: create an object to encapsulate all those data, then you can say,