Java – Important FAQ on String & StringBuffer | Code Factory


Index Page : Link

Donate : Link

Medium Link : Link

Applications : Link

1. Why SCP concpt is available only for String object but not for StringBuffer

– Ex. If one person is regular customer to some shop then special privilages given to him but if this person is go only once a year or month then special privilages not given to him. Thats why SCP is available to String but not for StringBuffer.

2. Why String objects are immutable where as StringBuffer objects are mutable.

– For String object SCP conecpt is there so reusability same object is there. So if any one object’s value is change then all the references are affected so immutability is required.

– In StringBuffer for every reference different object is there because reusing same object is no there, If we change any StringBuffer object it will not affect other objects because there is no SCP

3. In addition to String objects any other objects are immutable in Java?

– All wrapper class objects

– Byte, Short, Integer, Long, Float, Double, Character, Boolean

3 thoughts on “Java – Important FAQ on String & StringBuffer | Code Factory”

  1. Undeniably believe that which you stated. Your favorite justification appeared to be on the internet the simplest thing to be aware of. I say to you, I definitely get irked while people consider worries that they plainly do not know about. You managed to hit the nail upon the top and also defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks

    Liked by 1 person

Leave a comment