Infosys Interview Question
Software Engineer / DevelopersWhen another string is appended to the original string without using string buffer, new String object is always created.
If we use StringBuffer then same object of StringBuffer gets modified/appended.
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannoot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hance saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
The strings are immutable and when required to change the value or append the value the operation cannot be performed in the same string hence we need to take a new string resulting in waste of memory.............
but when we use string buffer we can perform any operation on that string like append etc hence it is very useful accurate and hence saves a lot of memory
StringBuffer saves memory, becouse any manipulation done to StringBuffer will not create a new memory ..insted the changes are done in the same memory..where as in String for each manipulation a new memory gets created in the Pool.
StringBuffer is variable in length in the sence it is mutable....!
String object in java is immutable... i.e. Once created they cannot be changed. Any time an operation is performed on them, a new String object is created and the values are copied over.
- Anonymous June 06, 2007StringBuffer is mutable. i.e, it can be changed.. so no copying is performed.