Run the code through the profiler (check speed and memory). When you find where it is slow (usually not where you think it is), find out what you can do to speed it up.
Another useful thing (if you are a little brave) is to use NetBeans 7.0 M2 (donβt worry too much, their non-releasing version is very stable) there is a plugin called βJackpotβ that searches for your code for refactoring. Some of them are related to performance ... but I do not think that any of them will make a radical change in speed.
Generally speaking, keep the code clean and easy to read, and it will be fast. When it's not fast, it will be easier for you to speed it up than if it were a mess.
What I did once when I was writing something that I knew was fast (it was code for parsing class files) was to start the profiler every time I made changes. So in one step, I decided to shorten memroy by calling String., An intern, to make sure all the lines were merged together. When I added the call to intern (), memry dropped a little, but the time increased by some huge amount (String.intern is too slow, or it was a few years ago). So, at that moment I knew that what I just did was inefficiently slow, and I canceled this change.
I do not recommend doing this in general development, but I run the code through the profiler once a day or once a week to see how this happens - this is not a performance killer.
source share