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


Please Help Members By Posting Answers For Below Questions

What is the purpose of format function?

869


How do you create an array in java?

766


What is the difference between a method and a function in alice?

825


How many bytes is a unicode character?

750


How can constructor chaining be done using this keyword?

958


What is a function easy definition?

752


What is thread pool? How can we create thread pool in java?

847


What is equlas() and hashcode() contract in java? Where does it used?

836


What is array class in java?

811


What is a percentage sign called?

832


How do you do a line break in java?

691


What is static block?

811


Can we declare a constructor as final?

932


Which collections are thread safe in java?

715


Why hashmap is used in java?

783