View RSS Feed

Advanced Java

Advanced Java programming.

  1. Unnecessary Object Creation with Immutable Objects

    by , 11-30-2011 at 12:05 AM
    Programmers are often not aware of how to create objects that can be reused. The key to understanding how to create reusable objects is that they must be immutable. So for example if you a running a loop in which each loop a string instance is required, rather than create a new instance every time it executes, you simply reuse the existing instance.

    Rather than create a new String instance.

    Java Code:
    public void BuildingLoop{
    	int total = 10;
    	for(int i=0;