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
What is multi level inheritance in java?
what are different ways in which a thread can enter the waiting state? : Java thread
What is the role of garbage collector in java?
Explain different ways of creating a thread. Which one would you prefer and why?
What is codebase?
What is a method in coding?
Can we override tostring method in java?
What is break and continue statement?
How many functional interfaces does java 8 have?
What do you mean by JVM?
Is string an object?
What class of exceptions are generated by the java run-time system?
What does sprintf return?
What is the most important feature of java? What is an interface?
Name few java util classes introduced with java 8 ?