However, using Boolean isn't that that. I believe that, unless you explicitly use new Boolean(boolean) that it's smart enough to use the static Boolean.TRUE and Boolean.FALSE rather that instantiating anything new.

Only 'optimize' or care about it, when you are 'profiling' and not because you think you are smarter than the compiler.

Most of the time people's optimization actually may make it worse. Do not rely on your 'gut' and intuition. Believe in the profiler! and what actual performance changes occur. when you try to optimize code.

At the very least, run some sample real world conditions to test it 'new optimization'

For those who have understanding of where you deal with computational time, O(n) for worst case, average case, best case. Just because you optimize for best case, doesn't mean you don't make a horrible worst or average case. So be cautious with your 'samples' and test conditions

While you are on your task you should use at least couple minutes to think if there are any oblivious performance problems in your code. It's lot faster and easier to modify code that is still fresh in your memory than later. If you only optimize later on. You end up optimizing couple obvious bottleneck and after that profiler will show that 80-90% of time is used for bulk code without any significant code paths left for optimizing if performance is still then problem you need to rewrite most of the code which is just total nightmare.

Best thing which will often produce better code is to THINK before you code. Draw or write down what classes you will need and the methods they might need. You will never get a perfect model but this will clear out many possible performance issues before any code is even there.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org