WebHosting

Thursday, April 26, 2012

trimToSize or trimTolength

This method is sometime very useful for memory management suppose you know value you have assigned to an array list will be final means no more element addition to the array list you can use this to make the memory smaller for that array list


Trims the capacity of this ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.


An application can use this operation to minimize the storage of an ArrayList instance. 


Example: 

     ArrayList myAL = new ArrayList();
      myAL.Add( "Shashwat" );
      myAL.Add( "Shriparv" );
So now you know that no more element will be added to myAl, so you can apply:

myAl.trimToSize() to make memory alocation smaller and efficient.

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

เค•िเคธเค•े เคนिเคธ्เคธे เคฎें เคฎें เคฏे เคงเคฐเคคी

เคšिเคก़िเคฏों เค•ा เค˜เคฐ เคœเคฒ เคฐเคนा เคนै  เค‡ंเคธाเคจ เค–ुเคถ เคนै เค•ि เคฏे เค†เค— เคฆूเคฐ เคนै เค…เคญी เค•เคญी เคคो เค†เคเค—ी เค˜เคฐ เคคเค•  เคคेเคฐा เคญी เค˜เคฐ เคœเคฒेเค—ा เค•เคญी เคฌेเคœुเคฌाเคจ เคนै เค•ुเค› เคฌोเคฒเคคे เคจเคนीं เคนै เคฆिเคฒ เคฎें เคฆुเค– ...