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 major drawback of internal iteration over external iteration?

589


What is the difference between import java.util.date and java .util?

574


Explain about the performance aspects of core java?

558


How many bytes is a string?

568


How do you find the maximum number from an array without comparing and sorting?

642






What are disadvantages of java?

524


What are keywords and reserved words in java?

562


What is the synonym of string?

543


What is the purpose of static methods and static variables?

544


If a method is declared as protected, where may the method be accessed?

537


How many ways can an argument be passed to a subroutine and explain them?

582


Why are global variables used?

506


When should the method invokelater() be used?

584


What do you mean by default constructor in java?

580


What do you mean by JVM?

592