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
what is the constructor and how many types of constructors are used in java?
What is an argument in java?
What java ide should I use?
If we don’t want some of the fields not to serialize how to do that?
What is the platform?
What is finalize()? Is finalize() similar to a destructor?
What is the protected method modifier?
How can you avoid serialization in child class if the base class is implementing the serializable interface?
Can you pass functions in java?
What are use cases?
What are the methods used to implement for the key object in the hash map?
What are annotations in java?
What is the exact difference in between unicast and multicast object? Where we will use?
What is static synchronization?
What is a generic code?