Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Search Your Question

Monday, May 5, 2008

Why string are called Immutable data Type ?

The contents of the String class cannot be changed. any method that you might expect to modify the contents actually returns a new instance of the string. The old instance remains in the memory untill its cleaned by the GC.

The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed . Thus keeping the Old string in Memory for Garbage Collector to be disposed.

No comments:

Archives