Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Java
Expertise: Advanced
May 5, 2009

Avoid Object Instantiation Within Loops

Avoid defining new objects within loop structures. Doing so hampers performance significantly, due to object creation overhead.

Instead, define objects outside the loop and then use them inside the loop. Moving object definitions out of your loops can often improve loop performance by nearly 100 percent.

If you want to see the actual effect, try using a profiler plugin such as jprobe or the Eclipse Test & Performance Tools Platform (TPTP) profiling tool.

Kulkarni Vasudeva
Thanks for your registration, follow us on our social networks to keep up-to-date