1.

Which among String or String Buffer should be preferred when there are lot of updates required to be done in the data?

Answer»

StringBuffer is MUTABLE and dynamic in nature whereas String is immutable. EVERY updation / modification of String creates a new String thereby overloading the string pool with unnecessary objects. Hence, in the CASES of a lot of UPDATES, it is always preferred to use StringBuffer as it will reduce the overhead of the creation of multiple String objects in the string pool.



Discussion

No Comment Found