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 are methods?
How do you break a loop?
What is variable declaration and definition?
What are different types of inner classes ?
Can You Have Virtual Functions In Java?
Is set thread safe java?
Can static method access instance variables ?
What is a nonetype?
What are the main uses of this keyword?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).
When do you call copy constructor?
Differences between C and Java?
Why java is considered as platform independent?
Why singleton class is used in java?
I want to print “hello” even before main is executed. How will you acheive that?