what is mutability?which one is mutable String or StringBuffer?and why?give
examples of each which shows the mutability of each String or StringBuffer
Answer Posted / arjunkumar
Mutability means data which we can change.
StringBuffer class is mutable, because it can change its
data where as String class cant.
Example:
If you want to combine two strings we have two methods i.e
append() method and concat() method.
here append() is used to append the 2nd string to 1st string
and it can store in memory. where as concat() method is
combine the 2nd string to 1st string but it is not actuly
stored in memory it just show to us as combind
| Is This Answer Correct ? | 4 Yes | 4 No |
Post New Answer View All Answers
How does list work in java?
What is finalize method?
What is defined as false sharing in the context of multithreading?
What is a singleton puppy?
Can an interface have a class?
What is an association?
How do you convert an int to a double in java?
Can a class be declared as static?
Is constructor inherited?
How to optimize the javac output?
What is a key in java?
Explain reverse a linked list iterative solution in java?
What is the use of set in java?
What are the advantages of java over C++?
What is the purpose of an interface?