Originally posted by shruti patel: string is immutable? right every one knows that, my question is it advantage or disadvantage making string immutable?
One of the advantages Immutable objects behave like primitive datatypes a bit. Like....
So we can use String objects as we use the primitives, except some cases like argument passing etc
One of the Disadvantages Whenever their(immutable objects') contents are tried to be changed, new objects are created and their references are assigned to the reference variable. Hence older objects are thrown floating in the HEAP,reducing usable memory size. I am giving the keyboard a rest here, because it takes a long to disscuss it in depth. Follow Kathy Sierra & Bert Bates. It will help you the best.