Answer Posted / gangabusi
String is immutable, we can not modify the string objects.
if we can create any string object
Ex: String S="Ganga";
here 'S' is string object created in heap memory.
I Want to add Something to S,
String S="Gangadhar";
Here In heap momory one more object is created for 'S',not
overridden.So that each and every updation String create
one new object in heap.
StringBuffer sb="Ganga"
here 'sb' is stringbuffer object created in heap memory.
I Want to add Something to sb,
StringBuffer sb="Gangadhar";
Here In heap momory 'sb' is overridden.So that each and
every updation StringBuffer create an object in stack.
It is mutable and it is Synchronized.(one thread process at
a time)
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Why is whitespace important?
Can we have more than one package statement in the source file?
Difference between static and dynamic class loading.
Explain about automatic type conversion in java?
When can you say a graph to be a tree?
What is the difference between integer parseint and integer valueof?
Is object a data type in java?
What do you understand by the term polymorphism?
What are encapsulation, inheritance and polymorphism?
What is pangram in java?
Is ++ operator is thread safe in java?
How to do a true java ping from windows?
What is a stringbuffer?
Tell me a few examples of final classes defined in Java API?
Can we have try without catch block?